在php中imagecreate函数是一个图形处理函数,主要用于新建一个基于调色板的图像了,然后在这个基础上我们可以创建一些图形数字字符之类的,但这个函数需要GD库支持,如果没有开启GD库使用时会
undefined
例,我在测试一个简单生成图形时实例
Example #1 新建一个新的 GD 图像流并输出图像
代码如下 | 复制代码 |
<?php |
运行机制时提示
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
本文来自博客园,作者:茄子_2008,转载请注明原文链接:https://www.cnblogs.com/xd502djj/p/4293180.html
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 一个费力不讨好的项目,让我损失了近一半的绩效!
· .NET Core 托管堆内存泄露/CPU异常的常见思路
· PostgreSQL 和 SQL Server 在统计信息维护中的关键差异
· C++代码改造为UTF-8编码问题的总结
· DeepSeek 解答了困扰我五年的技术问题
· 清华大学推出第四讲使用 DeepSeek + DeepResearch 让科研像聊天一样简单!
· 推荐几款开源且免费的 .NET MAUI 组件库
· 实操Deepseek接入个人知识库
· 易语言 —— 开山篇
· 【全网最全教程】使用最强DeepSeekR1+联网的火山引擎,没有生成长度限制,DeepSeek本体