PHP uses GD library to draw and generate verification code pictures

Source: Internet
Author: User
Tags function examples
PHP uses GD library to draw and generate verification code pictures

First you have to determine if the php.ini setting has the GD extension function, test the following

Print_r (Gd_info ());

If there is a printout of the content as follows, then the GD feature is open:

Array (    [GD Version] = bundled (2.0.34 compatible)    [FreeType support] + 1    [FreeType Linkage] = Wit H 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] =)

GD drawing general steps are as follows:

1. Create a canvas resource

2. Create a color brush

3. Drawing

4. Save picture or Output picture

5. Destroying the Memory canvas resource


The test code is as follows:

 

The test image is as follows:



Note: GD library powerful can draw various reports (such as histogram, pie chart, etc.), thumbnails, watermark and stock charts

Thumbnail function Examples:

 
  


  • 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.