PHP GD库中不支持PNG,但具有GIF和JPEG支持.我怎样才能解决这个问题? [英] No PNG support in PHP GD Library but has GIF and JPEG Support. How can I fix this?

查看:576
本文介绍了PHP GD库中不支持PNG,但具有GIF和JPEG支持.我怎样才能解决这个问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在OS X Yosemite上运行MAMP服务器3.0.5版.在执行期间,我的php文件似乎缺少PNG支持 甚至在我拥有MAMP 2.1之前,它就存在与png相关的功能的致命错误.

I am running MAMP server Version 3.0.5 on OS X Yosemite. It seems to be missing PNG Support on my php files during execution Even before when I had MAMP 2.1, it had fatal errors on png related functions.

Jpeg函数可以正常工作.

The Jpeg functions work fine though.

这是我的phpinfo的样子:

This is what my phpinfo looks like :

Build Date  Apr 10 2014 17:21:18
Configure Command   './configure' '--with-mysql=/Applications/MAMP/Library' '--with-apxs2=/Applications/MAMP/Library/bin/apxs' '--with-gd' '--with-jpeg-dir=/Applications/MAMP/Library' '--with-png-dir=/Applications/MAMP/Library' '--with-zlib' '--with-zlib-dir=/Applications/MAMP/Library' '--with-freetype-dir=/Applications/MAMP/Library' '--prefix=/Applications/MAMP/bin/php/php5.5.10' '--exec-prefix=/Applications/MAMP/bin/php/php5.5.10' '--sysconfdir=/Applications/MAMP/bin/php/php5.5.10/conf' '--with-config-file-path=/Applications/MAMP/bin/php/php5.5.10/conf' '--enable-ftp' '--enable-gd-native-ttf' '--with-bz2=/usr' '--with-ldap' '--with-mysqli=/Applications/MAMP/Library/bin/mysql_config' '--with-t1lib=/Applications/MAMP/Library' '--enable-mbstring=all' '--with-curl=/Applications/MAMP/Library' '--enable-sockets' '--enable-bcmath' '--with-imap=shared,/Applications/MAMP/Library/lib/imap-2007f' '--enable-soap' '--with-kerberos' '--enable-calendar' '--with-pgsql=shared,/Applications/MAMP/Library/pg' '--enable-exif' '--with-libxml-dir=/Applications/MAMP/Library' '--with-gettext=shared,/Applications/MAMP/Library' '--with-xsl=/Applications/MAMP/Library' '--with-pdo-mysql=shared,/Applications/MAMP/Library' '--with-pdo-pgsql=shared,/Applications/MAMP/Library/pg' '--with-mcrypt=shared,/Applications/MAMP/Library' '--with-openssl' '--enable-zip' '--with-iconv=/Applications/MAMP/Library' '--enable-opcache' '--enable-intl' '--with-tidy=shared' '--with-icu-dir=/Applications/MAMP/Library'

这是GD部分包含的内容:

And this is what the GD section contains :

GD Support  enabled
GD Version  bundled (2.1.0 compatible)
FreeType Support    enabled
FreeType Linkage    with freetype
FreeType Version    2.4.12
T1Lib Support   enabled
GIF Read Support    enabled
GIF Create Support  enabled
JPEG Support    enabled
libJPEG Version 8
PNG Support enabled
libPNG Version  1.6.6
WBMP Support    enabled
XBM Support enabled

要测试该代码存在的png执行和gd库,我运行以下代码:

To test the png execution and gd library existing for the code, I run the following code :

if (extension_loaded('gd')) {
  echo "\nGD support is -Loaded-";
}else{
  echo "\nGD support is == NOT == loaded ";
}
if(function_exists('gd_info')){
  echo "\nGD function support is -Available- ";
}else{
  echo "\nGD function support is == NOT == available ";
}

if(function_exists('imagepng')){
  echo "\nimagepng() -Exists-";
}else{
  echo "\nimagepng() ==== DOES NOT ==== Exist";
}


if(function_exists('imagejpeg')){
  echo "\nimagejpeg() -Exists-";
}else{
  echo "\nImage Function ==== DOES NOT ==== Exists";
}

这就是我得到的结果:

我注意到的一件事是GD中的libPNG版本为"1.6.6",而我计算机上的版本为"1.6.12".可能会导致PNG功能出现问题吗?

One thing I do notice is that the libPNG Version in GD is '1.6.6', whereas the one on my computer is '1.6.12'. Is it a possibility that it causes a problem with the PNG functions?

推荐答案

对于那些出现相同症状(使用优胜美地的PHP和GD Lib有效但缺少PNG支持)的人来说,这是一个答案. OS X随附的PHP(而不是MAMP).

This is an answer for those who come here with the same symptom (PHP under Yosemite with GD Lib active but missing PNG support) but who are using the Apache and PHP that comes with OS X (instead of MAMP).

在这种情况下,出现问题的原因是优胜美地的PHP随附了未编译的PNG和FreeType支持.

In this case the reason for the problem is that Yosemite's PHP comes without PNG and FreeType support compiled in.

此处介绍了这种情况下的解决方案: https://stackoverflow.com/a/26505558/430742

The solution in this situation is described here: https://stackoverflow.com/a/26505558/430742

这篇关于PHP GD库中不支持PNG,但具有GIF和JPEG支持.我怎样才能解决这个问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆