Install the GD library to resolve thinkphp verification code call to undefined function think\imagecreate () error

Source: Internet
Author: User
Tags install php

Tag: Ade code BSP prompts AC str to run BLE generation

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

<?php header ("Content-type:image/png"); $im = @imagecreate (+) 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 for the operation: Run the command to install PHP with the GD library online:

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 everything in php.ini this file, just need to write *.ini file in the/etc/php.d/folder Yes, the system will automatically read the *.ini in this directory into php.ini/usr/lib/php/modules/gd.so <----This is GD's file.

Install the GD library to resolve thinkphp verification code call to undefined function think\imagecreate () error

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.