Home » Code » PHP » PHP安装——启用了GD,却用不了jpeg的相关函数?


最近编译安装PHP,编译参数明明写了–with-gd,phpinfo()查看也看到“GD Support enabled”。但实际使用时却报Call to undefined function imagecreatefromjpeg(),顿时茫然。一阵搜索,看到这么个说法:

If imagecreatefromjpeg() fails with “PHP Fatal error: Call to undefined function: imagecreatefromjpeg()”, it does NOT necessarily mean that you don’t have GD installed.

If phpinfo() shows GD, but not JPEG support, then that’s the problem. You would think that –with-gd would do the right thing since it does check for the existance of libjpeg (and finds it) and add that feature to GD, but it doesn’t in v4.4.4 at least on RHEL v2.1, RHEL v3, CentOS v2.1 or CentOS v4.3.

On those platforms, it’s *important* that –with-jpeg-dir be *before* –with-gd. If it’s not, GD won’t build with jpeg support as if –with-jpeg-dir had never been specified…


显然的看到PNG Support,却没有JPEG Support。打印gd_info()的结果能明确看到jpeg_support => false。正确的方式是还得加一句–with-jpeg-dir(前提是安装了jpeg相关的库,不是默认安装估计还得指定具体路径),坑!



Leave a Reply

Your email address will not be published. Required fields are marked *


Time limit is exhausted. Please reload CAPTCHA.