October 2002
Intermediate to advanced
368 pages
7h 12m
English
Once you have configured PHP to use the GD library, you can start creating some graphics.
The base function to use when creating images using the GD library is the ImageCreate() function.
$length = 300; $width = 100; $image = ImageCreate($length, $width);
Once you have created an image, you need to add some color to it using the ImageColorAllocate() function. ImageColorAllaocate() takes as its arguments the image you are creating and an RGB color value:
$blue = ImageColorAllocate($image, 0, 0, 255);
So now you have created a box and given it a color. Now all that is left is to display the image in a browser. To do that, you need two more lines of code:
Header("Content-type: image/png"); ImagePNG($image); ...Read now
Unlock full access