php提示Fatal error: Call to undefined function imagecreate()

在php中imagecreate函数是一个图形处理函数,主要用于新建一个基于调色板的图像了,然后在这个基础上我们可以创建一些图形数字字符之类的,但这个函数需要GD库支持,如果没有开启GD库使用时会

undefined

在php中imagecreate函数是一个图形处理函数,主要用于新建一个基于调色板的图像了,然后在这个基础上我们可以创建一些图形数字字符之类的,但这个函数需要GD库支持,如果没有开启GD库使用时会提示Call to undefined function imagecreate()错误。

例,我在测试一个简单生成图形时实例

Example #1 新建一个新的 GD 图像流并输出图像

 代码如下 复制代码

<?php
header("Content-type: image/png");
$im = @imagecreate(100, 50)
    or die("Cannot Initialize new GD image stream");
$background_color = imagecolorallocate($im, 255, 255, 255);
$text_color = imagecolorallocate($im, 233, 14, 91);
imagestring($im, 1, 5, 5,  "A Simple Text String", $text_color);
imagepng($im);
imagedestroy($im);
?>

运行机制时提示

Fatal error: Call to undefined function imagecreate() .....

后面突然想起没打开gd库了

这一问题是:GD库没有正确安装或配置,解决方案:

在php.ini中找到
;extension=php_gd2.dll
去掉前边的;
然后将php目录中的ext下的php_gd2.dll拷入c:/windows/system32和c:/windows目录下,重启IIS或者apache就OK了.

centos中gd库开启

具体操作只有2个命令如下:
运行在线安装带GD库的PHP的命令:

 代码如下 复制代码
yum -y install php-gd

重新启动apachce服务以使安装后的GD库生效

 代码如下 复制代码
/etc/rc.d/init.d/httpd restart(service httpd restart)

gd的安装路径

/etc/php.d/gd.ini                 <---这个是让php支持gd的哦,这个是CentOS的特色之一,不用把全部东西都写在php.ini这个文件里,只是需要把*.ini文件写在/etc/php.d/文件夹就可以了,系统会自动把这个目录下的*.ini读入php.ini
/usr/lib/php/modules/gd.so   <----这个就是gd的文件啦

关于需要使用GD库的图形处理函数还有如下

gd_?info
 
getimagesize
 
getimagesizefromstring
 
image_?type_?to_?extension
 
image_?type_?to_?mime_?type
 
image2wbmp
 
imageaffine
 
imageaffinematrixconcat
 
imageaffinematrixget
 
imagealphablending
 
imageantialias
 
imagearc
 
imagechar
 
imagecharup
 
imagecolorallocate
 
imagecolorallocatealpha
 
imagecolorat
 
imagecolorclosest
 
imagecolorclosestalpha
 
imagecolorclosesthwb
 
imagecolordeallocate
 
imagecolorexact
 
imagecolorexactalpha
 
imagecolormatch
 
imagecolorresolve
 
imagecolorresolvealpha
 
imagecolorset
 
imagecolorsforindex
 
imagecolorstotal
 
imagecolortransparent
 
imageconvolution
 
imagecopy
 
imagecopymerge
 
imagecopymergegray
 
imagecopyresampled
 
imagecopyresized
 
» imagecreate
 
imagecreatefromgd2
 
imagecreatefromgd2part
 
imagecreatefromgd
 
imagecreatefromgif
 
imagecreatefromjpeg
 
imagecreatefrompng
 
imagecreatefromstring
 
imagecreatefromwbmp
 
imagecreatefromwebp
 
imagecreatefromxbm
 
imagecreatefromxpm
 
imagecreatetruecolor
 
imagecrop
 
imagecropauto
 
imagedashedline
 
imagedestroy
 
imageellipse
 
imagefill
 
imagefilledarc
 
imagefilledellipse
 
imagefilledpolygon
 
imagefilledrectangle
 
imagefilltoborder
 
imagefilter
 
imageflip
 
imagefontheight
 
imagefontwidth
 
imageftbbox
 
imagefttext
 
imagegammacorrect
 
imagegd2
 
imagegd
 
imagegif
 
imagegrabscreen
 
imagegrabwindow
 
imageinterlace
 
imageistruecolor
 
imagejpeg
 
imagelayereffect
 
imageline
 
imageloadfont
 
imagepalettecopy
 
imagepalettetotruecolor
 
imagepng
 
imagepolygon
 
imagepsbbox
 
imagepsencodefont
 
imagepsextendfont
 
imagepsfreefont
 
imagepsloadfont
 
imagepsslantfont
 
imagepstext
 
imagerectangle
 
imagerotate
 
imagesavealpha
 
imagescale
 
imagesetbrush
 
imagesetinterpolation
 
imagesetpixel
 
imagesetstyle
 
imagesetthickness
 
imagesettile
 
imagestring
 
imagestringup
 
imagesx
 
imagesy
 
imagetruecolortopalette
 
imagettfbbox
 
imagettftext
 
imagetypes
 
imagewbmp
 
imagewebp
 
imagexbm
 
iptcembed
 
iptcparse
 
jpeg2wbmp
 
png2wbmp

undefined

http://www.android100.org/html/201407/11/38612.html

时间: 2024-07-31 14:30:25

php提示Fatal error: Call to undefined function imagecreate()的相关文章

[乐意黎原创] php 页面提示 Fatal error: Call to undefined function curl_init()

调用到 curl_init()的php页面提示: Fatal error: Call to undefined function curl_init() in E:\PHPCMS\Cms\www.aerchi.com\kuaiji\weixin.php on line 196 如图: 首先, 在 php.ini 文件中开启 extension=php_curl.dll , 即把把前面的分号(;)注释划掉. 如果是 windows 7 系统(需要openssl),还需要把 extension=ph

linux重新编译安装gd,增加freetype支持,解决验证码不显示问题,Fatal error: Call to undefined function imagettftext()

问题: Fatal error: Call to undefined function Think\imagettftext() in /var/www/webreg/ThinkPHP/Library/Think/Verify.class.php on line 143 查看phpinfo()后得知,gd中没有freetype的支持 解决: 首先安装freestyle,php-gd 确保先安装freestyle,然后是php-gd:如果是先安装了php-gd,那么在安装完freestyle后,需

PHP Fatal error: Call to undefined function json_decode()

php:5.5,操作系统:ubuntu13.10 网站文本编辑器使用的是ueditor,测试上传图片显示后台配置项未成功加载,上传插件不能正常使用. 查阅了ueditor的文档,有关运行测试那里先访问ueditor/controller.php,提示出错,再访问ueditor/php/controller.php?action=config,提示PHP Fatal error: Call to undefined function json_decode().原因是json相关函数为定义. 查看

PHP Fatal error: Call to undefined function imagettftext()

PHP Fatal error: Call to undefined function imagettftext() 一.问题描述 安装了环境,发现验证码显示不了,查看日志:error: Call to undefined function imagettftext(),然后你去搜索百度,原因千千万,帖子里的解决方法也千千万,有的是缺gd库支持(没安装),也有可能是gd库要依赖的库等没有安装,或者说是库版本不匹配等,笔者我也捣弄了一大堆解决方式,最后的建议还是重新编译安装php,各种曲折大家可以

Fatal error: Call to undefined function imagettftext()解决办法

Fatal error: Call to undefined function imagettftext()解决办法 我的问题是php编译安装时指定了gd的目录,其实不用指定.就可以了 博客分类: php freestylephpcmsconfigure  问题描述:phpcms 安装后,不能看到验证码图片. 解决:确保php-gd和freestyle.而且确保是先安装了freestyle,然后是php-gd:如果是先安装了php-gd,那么在安装完freestyle后,需要make clean

PHP Fatal error: Call to undefined function mysql_pconnect()

[[email protected] caishenye]# tail -f /data/caishenye/sa_9_0.log PHP Warning:  mkdir(): No such file or directory in /data/caishenye/sa_9_0.php on line 18 PHP Fatal error:  Call to undefined function mysql_pconnect() in /data/caishenye/sa_9_0.php on

fatal error: Call to undefined function mysqli_connect()

在搭建PHP5.6+APACHE2.4+MYSQL5的平台时,测试是否成功连接mysql, 测试程序index.php <?php phpinfo() ?> 没有出现mysql的信息 所以使用另外一个程序来连接mysql <?php$link=mysqli_connect("127.0.0.1","root","");if($link!=false){ echo "succeed in connecting to my

Fatal error: Call to undefined function pasterTempletDiy()

下面也简单说下这个函数的作用,主要用于dedecms留言板页面调用头部尾部文件,放到DEDE的外部函数接口文件里就可以了,具体路径位如根目录include文件夹下extend.func.php. 在extend.func.php 文件底部附加如下代码: function pasterTempletDiy($path) { require_once(DEDEINC."/arc.partview.class.php"); global $cfg_basedir,$cfg_templets_

Fatal error: Call to undefined function fnmatch() 解决

我的PHP版本是5.6.30,linux 是CentOS 6.6,nginx,也不知啥问题,看了官方: https://secure.php.net/manual/en/function.fnmatch.php 上面有段警告: Warning For now, this function is not available on non-POSIX compliant systems except Windows.  大致意思fnmatch不能在除windows以外非POSIX系统上使用, 下面也