Jquery中文网 www.jquerycn.cn
Jquery中文网 >  脚本编程  >  php  >  正文 php Fatal error: Call to undefined function imagecreatefromjpeg()

php Fatal error: Call to undefined function imagecreatefromjpeg()

发布时间:2018-09-08   编辑:www.jquerycn.cn
jquery中文网为您提供php Fatal error: Call to undefined function imagecreatefromjpeg()等资源,欢迎您收藏本站,我们将为您提供最新的php Fatal error: Call to undefined function imagecreatefromjpeg()资源
imagecreatefromjpeg函数是一个图像处理函数,但在使用中发现Fatal error: Call to undefined function imagecreatefromjpeg()错误了,下文小编整理了一些教程,大家一起来看看吧。

代码

<table width="620" align="center" border="0" cellpadding="1" cellspacing="1" style="background:#FB7"> <tr> <td width="464" height="27" bgcolor="#FFE7CE"> 代码如下</td> <td width="109" align="center" bgcolor="#FFE7CE" style="cursor:pointer;" onclick="doCopy('copy6373')">复制代码</td> </tr> <tr> <td height="auto" colspan="2" valign="top" bgcolor="#FFFFFF" style="padding:10px;" class="copyclass" id=copy6373>

if(!imagecreatefromjpeg("./testimg.jpg"))
{
echo "imagecreatefromjpeg(testimg.jpg) failed!n)";
}
else
{
echo "imagecreatefromjpeg(testimg.jpg) succn)";
}

如果你使用此函数提示php Fatal error: Call to undefined function imagecreatefromjpeg()

这个错误是因为没有安装gd 的jpeg, 虽然你用phpinfo 查看有gd但 gd 不支持 jpeg

安装前我的phpinfo 如下:
gd
GD Support enabled
GD Version bundled (2.0.34 compatible)
FreeType Support enabled
FreeType Linkage with freetype
FreeType Version 2.2.1
GIF Read Support enabled
GIF Create Support enabled
PNG Support enabled
libPNG Version 1.2.10
WBMP Support enabled
XBM Support enabled

显然gd 没有支持jpeg 的,下面要安装 gd中的 jpeg

<table width="620" align="center" border="0" cellpadding="1" cellspacing="1" style="background:#FB7"> <tr> <td width="464" height="27" bgcolor="#FFE7CE"> 代码如下</td> <td width="109" align="center" bgcolor="#FFE7CE" style="cursor:pointer;" onclick="doCopy('copy6124')">复制代码</td> </tr> <tr> <td height="auto" colspan="2" valign="top" bgcolor="#FFFFFF" style="padding:10px;" class="copyclass" id=copy6124>

1、找到php 源码目录
2、进入 ext/gd 目录
3、/usr/local/php/bin/phpize
4、./configure –with-php-config=/usr/local/php/bin/php-config –with-jpeg-dir –with-freetype-dir
5、make && make install
6、重启 httpd

安装后查看phpinfo

gd
GD Support enabled
GD Version bundled (2.0.34 compatible)
FreeType Support enabled
FreeType Linkage with freetype
FreeType Version 2.2.1
GIF Read Support enabled
GIF Create Support enabled
JPEG Support enabled
libJPEG Version 6b
PNG Support enabled
libPNG Version 1.2.10
WBMP Support enabled
XBM Support enabled

很显然多了个 JPEG Support enabled

以windows下的php apache

首先,打开php.ini,找到“extension=php_gd.dll”,然后去掉前面的“;”注释,重启apache即可。

如果还出现此类问题,先检查php.ini的extension_dir值是哪个目录,在那个目录下检查有无php_gd.dll,没有的话请下载php_curl.dll,再把php目录中的libeay32.dll和ssleay32.dll拷到c:windowssystem32里面,重启apache,OK!

您可能感兴趣的文章:
解决Magento报错:Fatal error: Call to undefined method
php Fatal error: Call to undefined function imagecreatefromjpeg()
php Fatal error: Call to undefined function mb_convert_encoding()
Fatal error: Call to undefined function curl_init
php提示Fatal error: Call to undefined function openssl_x509_parse()
PHP Fatal error: Call to undefined function bcmul()
Fatal error: Call to undefined function
帝国cms设置及服务器本身问题引起的错误提示解决方法
php提示Fatal error: Call to undefined function imagecreate()
windows 下 php curl 的支持配置方法

[关闭]