php提示Fatal error: Call to undefined function imagecreate()
发布:smiling 来源: PHP粉丝网 添加日期:2014-09-21 21:29:02 浏览: 评论:0
在php中imagecreate函数是一个图形处理函数,主要用于新建一个基于调色板的图像了,然后在这个基础上我们可以创建一些图形数字字符之类的,但这个函数需要GD库支持,如果没有开启GD库使用时会提示Call to undefined function imagecreate()错误.
例,我在测试一个简单生成图形时实例,新建一个新的 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);
- //开源软件:phpfensi.com
- ?>
运行机制时提示: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
Tags: Fatal error:Call to undefined
相关文章
- ·Fatal error: Call to undefined function curl_init(2013-11-28)
- ·Fatal error: Cannot redeclare 常见问题(2013-11-29)
- ·php中Fatal error: Class ZipArchive not found的解决办法(2013-12-02)
- ·php错误Fatal error: Out of memory (allocated 262144)(2013-12-04)
- ·Fatal error: Out of memory (allocated 786432)提示解决办法(2013-12-04)
- ·Fatal error: Maximum execution time of 30 错误(2013-12-04)
- ·Fatal Error: Allowed memory size of 123456789 bytes exhausted(2013-12-04)
- ·PHP 报错 Fatal error: Class 'COM' not found in(2013-12-05)
- ·PHP Fatal error: Cannot use object of type stdClass as array in错误(2014-09-20)
- ·php程序执行超时解决办法(Fatal error: Maximum execution time of 30)(2014-09-21)
- ·Fatal error: Allowed memory size of 134217728 bytes exhauste(2014-09-21)
- ·php Fatal error: Call to undefined function imagecreatefromjpeg()(2015-04-04)
- ·php Fatal error: Call to undefined function mb_convert_encoding()(2015-04-04)
- ·php提示Fatal error: Call to undefined function openssl_x509_parse()(2015-04-04)
- ·php使用ZipArchive提示Fatal error: Class ZipArchive not found in(2015-04-09)
- ·Fatal error: Access level to xxx must be protected 错误解决(2016-08-25)
推荐文章
热门文章
最新评论文章
- 写给考虑创业的年轻程序员(10)
- PHP新手上路(一)(7)
- 惹恼程序员的十件事(5)
- PHP邮件发送例子,已测试成功(5)
- 致初学者:PHP比ASP优秀的七个理由(4)
- PHP会被淘汰吗?(4)
- PHP新手上路(四)(4)
- 如何去学习PHP?(2)
- 简单入门级php分页代码(2)
- php中邮箱email 电话等格式的验证(2)