First of all to determine whether the php.ini settings to open the GD extension function, the test is as follows
Print_r (Gd_info ());
If there is a printout of the contents below, then the GD function is open:
Array
(
[GD Version] => bundled (2.0.34 compatible)
[FreeType Support] => 1
[FreeType linkage] =& Gt 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] =>
)
GD Paint general steps 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:
!--? php header (content-type:image/jpeg); $width = 400;
Wide, high $height = 400; $image = Imagecreate ($width, $height); First step: Create a blank image $white = imagecolorallocate ($image, 0, 0, 0);
The first call to Imagecolorallocate () fills the background color of the palette-based image, which is the image created with Imagecreate (). $green = imagecolorallocate ($image, 0, 255, 0); Step Two: Assign color to the image imageline ($image, 0, M, $green); Step three: Draw line Imagerectangle ($image, 100,40,300,100, $green); Draw rectangular Imagearc ($image, 0, 360, $green); Draw round imagestring ($image, MB, M, PHP is Niubi honghong!, $green);
Write String $str =abcdefghjklmnpqrstuvwxyz23456789;
$randstr = substr (Str_shuffle ($STR), 0,4); Imagestring ($image, $randstr, $green); Verification Code Imagettftext ($image, 0, N, $green, & #39;/msjhbd. ttf& #39, Chinese vsenglish); Chinese validation//imagejpeg ($image, & #39;/test.jpg& #39;); Save the picture under the current path as Test.jpg imagejpeg ($image); Fourth step: Without file name, direct output to the Web page Imagedestroy ($image); Step Fifth: Destroy, Recycle resources?-->
The test picture is as follows:
Note: GD library powerful can draw a variety of reports (such as histogram, pie chart, etc.), thumbnails, plus watermark and stock trend chart