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

简介: 原文:php提示Fatal error: Call to undefined function imagecreate() 在php中imagecreate函数是一个图形处理函数,主要用于新建一个基于调色板的图像了,然后在这个基础上我们可以创建一些图形数字字符之类的,但这个函数需要GD库支持,如果没...
+关注继续查看
原文: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

目录
相关文章
|
1月前
|
存储 SQL 关系型数据库
PHP的学习与MYSQL高级 2
PHP的学习与MYSQL高级
34 0
|
1月前
|
关系型数据库 MySQL PHP
PHP的学习与MYSQL高级 1
PHP的学习与MYSQL高级
29 0
|
1月前
|
运维 关系型数据库 MySQL
【运维知识进阶篇】集群架构-Nginx实现基础web架构(Linux+Nginx+PHP+Mysql)(二)
【运维知识进阶篇】集群架构-Nginx实现基础web架构(Linux+Nginx+PHP+Mysql)(二)
80 0
|
1月前
|
运维 关系型数据库 MySQL
【运维知识进阶篇】集群架构-Nginx实现基础web架构(Linux+Nginx+PHP+Mysql)(一)
【运维知识进阶篇】集群架构-Nginx实现基础web架构(Linux+Nginx+PHP+Mysql)
61 0
|
2月前
|
SQL 缓存 关系型数据库
php开发实战分析(7):mysql类库操作的高级使用
php开发实战分析(7):mysql类库操作的高级使用
74 0
|
2月前
|
SQL 安全 关系型数据库
php开发实战分析(8):mysql类库的操作高级使用API开发(字段操作、权限分配、日期格式、跨表查询,数据分表)
php开发实战分析(8):mysql类库的操作高级使用API开发(字段操作、权限分配、日期格式、跨表查询,数据分表)
248 0
|
2月前
|
SQL 关系型数据库 MySQL
php开发实战分析(1):mysql操作字段(添加、删除、修改,多数据表中新增多个字段)
php开发实战分析(1):mysql操作字段(添加、删除、修改,多数据表中新增多个字段)
57 0
|
2月前
|
SQL JavaScript 前端开发
ChatGPT工作提效之在程序开发中的巧劲和指令(创建MySQL语句、PHP语句、Javascript用法、python的交互)
ChatGPT工作提效之在程序开发中的巧劲和指令(创建MySQL语句、PHP语句、Javascript用法、python的交互)
140 0
|
2月前
|
SQL JSON 关系型数据库
php执行语句在MySQL批量插入大数据量的解决方案及计算程序执行时间(大数据量、MySQL语句优化)
php执行语句在MySQL批量插入大数据量的解决方案及计算程序执行时间(大数据量、MySQL语句优化)
85 1
|
PHP 数据格式 XML
PHP Fatal error: Class &#39;DOMDocument&#39; not found
PHP Fatal error:  Class 'DOMDocument' not found 给PHP添加 xml模块: yum install php-xml   如果是PHP5,则用 yum install php55w-xml
875 0
相关产品
云迁移中心
推荐文章
更多