现在的位置: 首页 > 综合 > 正文

PHP:运行错误undefined imagecreatefromjpeg和undefined exif_imagetype

2014年04月02日 ⁄ 综合 ⁄ 共 900字 ⁄ 字号 评论关闭

安装环境是CentOS6.2+PHP5.3.28,PHP已编译过。

1. 如果发现exif_imagetype调用导致fatal error

那么检查exif扩展有没有安装,扩展的动态安装方法是使用phpize(php install zend extension)

	cd /root/php-5.3.28/ext/@extension-name@
	phpize (this command will generate compile configure file 4 the module)
	./configure --with-php-config=@php-config-path@
	make && make install 
	(@extension@.so will be installed under extension dir:@php-5.3.28-path@/lib/php/extensions/no-debug-non-zts-20090626/)

然后在php.ini文件中添加扩展:

extension=@extension-name@.so

2.如果是imagecreatefromjpeg导致fatal error

那么检查gd扩展有没有安装,方法同上

重启httpd服务后,检查phpinfo的信息,确认png/gif/jpeg都得到支持

如果只有PNG/GIF Support,而没有JPEG Support那一项,那意味着libjpeg没有被编译进GD2.1里面去,

首先安装jpeg:

tar zxvf jpegsrc.v8d.tar.gz 
cd jpeg-8d/
./configure --prefix=/usr/local/jpeg --enable-shared
make && make install

然后重新编译GD:

cd ../gd
phpize
./configure --with-jpeg-dir=/usr/local/jpeg --with-php-config=@php-config-path@
make clean
make && make install

如果GD已编译过,那么上面的make clean是必须的,否则不起作用。

重启httpd服务即可。

by iefreer

抱歉!评论已关闭.