CODE
<?php
header("Content-type: image/png");
$im = @imagecreate(100, 50)
or die("Cannot Initialize new GD image stream");
$background_color = imagecolorallocate($im, 255, 255, 255);
$text_color = imagecolorallocate($im, 233, 14, 91);
imagestring($im, 1, 5, 5, "A Simple Text String", $text_color);
imagepng($im);
imagedestroy($im);
?>
header("Content-type: image/png");That makes it output as an image rather than just a load of text.
$im = @imagecreate(100, 50)
or die("Cannot Initialize new GD image stream");Creates a blank image of 100,50 or it outputs the error message.
$background_color = imagecolorallocate($im, 255, 255, 255);
$text_color = imagecolorallocate($im, 233, 14, 91);Just sets some colours to some variables, the numbers are RGB.
imagestring($im, 1, 5, 5, "A Simple Text String", $text_color);Writes a string onto your image.
bool imagestring ( resource image, int font, int x, int y, string s, int col )
imagestring() draws the string s in the image identified by image with the upper-left corner at coordinates x, y (top left is 0, 0) in color col. If font is 1, 2, 3, 4 or 5, a built-in font is used.
imagepng($im);
imagedestroy($im);Displays and then destroys the image to free memory.