PHP hint fatal error:call to undefined function imagecreate () _php Tutorial

Source: Internet
Author: User
Tags php online
In PHP, the Imagecreate function is a graphics processing function, mainly used to create a new color palette-based image, and then on this basis we can be created some graphics numeric characters and the like, but this function requires the GD library support, if you do not open the GD library use will prompt call to Undefined function imagecreate () error.

example, I was testing an instance of a simple build graph

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

The code is as follows Copy Code

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);
?>

Prompt when operating mechanism

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

The back suddenly remembered that the GD library had not been opened

The problem is: The GD library is not properly installed or configured, the solution:

Found in php.ini
; Extension=php_gd2.dll
Remove the front;
Then copy the Php_gd2.dll under ext in the PHP directory into the c:/windows/system32 and c:/windows directories, restart IIS or Apache OK.

GD Library opens in CentOS

There are only 2 commands to do this:
Run the command to install PHP online with the GD library:

The code is as follows Copy Code
Yum-y Install PHP-GD

Restart the APACHCE service for the post-installation GD library to take effect

The code is as follows Copy Code
/ETC/RC.D/INIT.D/HTTPD Restart (Service httpd restart)

Installation path of GD

/etc/php.d/gd.ini <---This is to let PHP support GD's Oh, this is one of the features of CentOS, do not have to write all the things in php.ini this file, just need to write *.ini files in the/etc/php.d/folder on it, The system will automatically read the *.ini in this directory into the php.ini
/usr/lib/php/modules/gd.so <----This is GD's file.

The following are some of the graphics processing functions that need to use the GD library

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

http://www.bkjia.com/PHPjc/633172.html www.bkjia.com true http://www.bkjia.com/PHPjc/633172.html techarticle in PHP imagecreate function is a graphics processing function, mainly used to create a new color palette-based image, and then on this basis we can build some graphical numeric characters such as ...

  • Related Article

    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.