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: