Php prompts Fatalerror: Calltoundefinedfunctionimagecreate () _ PHP Tutorial

Source: Internet
Author: User
Php prompts Fatalerror: Calltoundefinedfunctionimagecreate (). In php, the imagecreate function is a graphic processing function. it is mainly used to create a palette-based image, then, we can create some graphics, numbers, and characters. in php, the imagecreate function is a graphic processing function, mainly used to create a palette-based image, then, we can create some graphical numbers and characters, but this function requires the support of the GD Library. if the GD library is not enabled, the Call to undefined function imagecreate () error will be prompted.

For example, when I test a simple graph generation instance

Example #1 create a new GD image stream and output the image

The code is as follows:

Header ("Content-type: image/png ");
$ Im = @ imagecreate (100, 50)
Or die ("Cannot Initialize new GD image stream ");
$ Background_color = imagecolorallocate ($ instant, 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 during running mechanism

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

I suddenly remembered that the gd database was not opened.

The problem is that the GD library is not correctly installed or configured. solution:

In php. ini, find
; Extension = php_gd2.dll
Remove the front edge;
Then, import the php_gd2.dll under ext in the php directory to the c:/windows/system32 and c:/windows directories, and restart IIS or apache.

Enable gd Library in centos

The specific operation only has two commands:
Run the following command to install PHP with GD Library online:

The code is as follows:
Yum-y install php-gd

Restart the apachce service to make the installed GD library take effect.

The code is as follows:
/Etc/rc. d/init. d/httpd restart (service httpd restart)

Gd installation path

/Etc/php. d/gd. ini <--- This is to allow php to support gd. this is one of the characteristics of CentOS and does not need to write everything in php. in the ini file, you just need to set *. the INI file is written in/etc/php. d/Folder. The system will automatically put *. ini is read into php. ini
/Usr/lib/php/modules/gd. so <---- this is the gd file.

The graph processing functions that require using the GD library are as follows:

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

20172wbmp

Png2wbmp

...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.