Call to undefined function imagecreatefromjpeg()
默认的php安装后gd不支持jpg,只支持gif、png、bmp
查看phpinfo
1 2 3 4 5 6 7 |
GD Support enabled GD Version 2.0 GIF Read Support enabled GIF Create Support enabled PNG Support enabled libPNG Version 1.2.10 WBMP Support enabled |
之前我曾经解决过,不过当时没留笔记,这次折腾了一天才弄出来,当一个教训吧。
隐约记得之前我配的没这么麻烦,如果你知道更简单的方法,请给我留言,先谢谢了。
重新安装gd
1 2 3 4 5 6 |
wget http://www.boutell.com/gd/http/gd-2.0.33.tar.gz tar zxvf gd-2.0.33.tar.gz cd gd-2.0.33 ./configure --prefix=/usr/local/gd2 make make instal |
重新编译php,指定gd2安装目录,如果不指定目录会在configure是报错
1 2 3 4 5 6 |
checking for jpeg_read_header in -ljpeg... yes If configure fails try --with-vpx-dir=<DIR> checking for png_write_image in -lpng... yes If configure fails try --with-xpm-dir=<DIR> checking for FT_New_Face in -lfreetype... yes configure: error: GD build test failed. ......... |
编译php
1 2 3 4 5 6 7 8 |
./configure --prefix=/usr/local/lnmp/php --enable-fpm --with-mcrypt --with-zlib --enable-mbstring --disable-pdo --with-curl --disable-debug --disable-rpath --enable-inline-optimization --with-bz2 --with-zlib --enable-sockets --enable-sysvsem --enable-sysvshm --enable-pcntl --enable-mbregex --with-mhash --enable-zip --with-pcre-regex --with-mysql --with-gd=/usr/local/gd2/ --with-jpeg-dir make make install |
编译时php5.4.7 安装出现 error: ‘struct gdIOCtx’ has no member named ‘data’
ext/gd/gd_ctx.c:67:8: error: ‘struct gdIOCtx’ has no member named ‘data’
解决方法:这个错误算是php5.4的bug?下面对应的两篇文章有对应的说明:
https://bugs.php.net/bug.php?id=55224
https://bugs.php.net/bug.php?id=60108
个人采用的方法:
vi <gd_dir>/include/gd_io.h
gdIOCtx结构中增加void *data;
gdparttopng.c:42: undefined reference to `gdImageCreateFromGd2Part’
yum install libjpeg-devel freetype-devel libpng-devel
make clean后重新./configure
make&make install
查看phpinfo
1 2 3 4 5 6 7 8 9 10 |
GD Support enabled GD Version 2.0 GIF Read Support enabled GIF Create Support enabled JPEG Support enabled libJPEG Version unknown PNG Support enabled libPNG Version 1.2.10 WBMP Support enabled |
虽然没有版本号,但是imagecreatefromjpeg()可以使用了。
终于有jpeg了
做好之后又出现了新问题,说没有可以被缩略的图像资源
我的是这个错误 是什么原因呢 PHPinfo 里面都是支持的呢 Call to undefined function imagecreatefrombmp()