PHP uses the GD library to draw pictures and generate verification code Pictures

Source: Internet
Author: User
PHP uses the GD library to draw pictures and generate verification code pictures. First, you must determine php. if the GD extension function is enabled in the ini settings, test print_r (gd_info (). if the following content is printed, the GD function is enabled: Array ([GDVersion] & gt; bundled (2.0.34compatible) [FreeTypeSupport] & gt; 1. use the GD library to draw and generate a verification code image.

First, check whether the GD extension function is enabled in the php. ini settings. the test is as follows:

print_r(gd_info());

If the following content is printed, the GD function is enabled:

Array(    [GD Version] => bundled (2.0.34 compatible)    [FreeType Support] => 1    [FreeType Linkage] => with freetype    [T1Lib Support] => 1    [GIF Read Support] => 1    [GIF Create Support] => 1    [JPG Support] => 1    [PNG Support] => 1    [WBMP Support] => 1    [XPM Support] =>     [XBM Support] => 1    [JIS-mapped Japanese Font Support] => )

The general steps of GD are as follows:

1. create a canvas resource

2. create a color paint brush

3. Drawing

4. save or output images

5. destroy memory canvas resources


The test code is as follows:

 

The test image is as follows:



Note: the GD database can draw various reports (such as bar charts and pie charts), thumbnails, watermarks, and stock trend charts.

Thumbnail function example:

 


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.