<?php
//general generated images can be png,jpg,gif,bmp
//jpeg,wbmp
//First step, set file MIME type, output type text/html type is Web page type, default can not write
Changing output type to Image stream
header (' content-type:image/png; ');
The second step, create a graphics area, image background
//There are two ways to create, resource type, generally add @ symbol, prevent error
//imagecreatetruecolor returns a resource handle//
This function creates an image area , the background is black
$im = Imagecreatetruecolor (200,200) when there is no padding;
The third step, has the blank image area, draws the color, the text is called, the line ah ...
//Fill color change, first have a color filler
//imagecolorallocate--For an image distribution color
$blue = imagecolorallocate ($im, 0,102,255);
Fill the blue color onto the background
//imagefill--area fill
imagefill ($im, 0,0, $blue);
Fourth, in the background of the blue input some lines, text and other
$white = Imagecolorallocate ($im, 255,255,255);
Imageline--Draw a line segment
imageline ($im, 0,0,200,200, $white);
Imageline ($im, 200,0,0,200, $white);
Imagestring-horizontally draw a line of strings
imagestring ($im, 5,80,20, ' Mr.one ', $white);
The fifth step, output final graphics
//in PNG format to output the image to the browser or file
imagepng ($im);
The sixth step, I want all the resources empty
Imagedestroy ($im);
? >