Home > Article > Backend Development > PHP prompts Fatal error: Call to undefined function imagecreate()_PHP tutorial
The imagecreate function in php is a graphics processing function. It is mainly used to create a new image based on the palette. Then on this basis we can create some graphics, digital characters, etc., but this function requires the support of the GD library , if the GD library is not enabled, a Call to undefined function imagecreate() error will be prompted.
Example, I am testing a simple generated graph
Example #1 Create a new GD image stream and output the image
The code is as follows | Copy code | ||||
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);?> |
Prompt when running the mechanism
Fatal error: Call to undefined function imagecreate() .....
This problem is: GD library is not installed or configured correctly, solution:
Found in php.ini
;extension=php_gd2.dll
代码如下 | 复制代码 |
yum -y install php-gd |
Then copy php_gd2.dll under ext in the php directory into the c:/windows/system32 and c:/windows directories, and restart IIS or apache and it will be OK.
代码如下 | 复制代码 |
/etc/rc.d/init.d/httpd restart(service httpd restart) |
gd installation path
/etc/php.d/gd.ini You just need to write the *.ini file in the /etc/php.d/ folder. The system will automatically read the *.ini in this directory into php.ini
/usr/lib/php/modules/gd.so <----This is the gd file
Regarding the graphics processing functions that need to use the GD library, there are the following
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
imagesethickness
imagesettile
imagestring
imagestringup
imagesx
imagesy
imagetruecolortopalette
imagettfbbox
imagettftext
imagetypes
imagewbmp
imagewebp
imagexbm
iptcembed
iptcparse
jpeg2wbmp
png2wbmp