Position Length Description
0 4 Number of characters in the font
4 4 ASCII value of first character
8 4 Width in pixels for each character
12 4 Height in pixels for each character
16 variableEach pixel uses 1 byte, so this field should be the product of the
number of characters, the width, and the height.
<?
/*
* Load a font and display some text
/
//create red square
$image = imagecreate(200,200);
$colorRed = imagecolorallocate($image, 255, 0, 0);
$colorBlack = imagecolorallocate($image, 0, 0, 0);
imagefill($image, 0, 0, $colorRed);
//load font
if(!($myFont = imageloadfont("myFont")))
{
print("Unable to load font!");
exit();
}
//draw some text with loaded font
imagestring($image, $myFont, 10, 10,
"Hello World!", $colorBlack);
//send image
header("Content-type: image/jpeg");
imagejpeg($image);
?>
boolean imagepng(integer image, string filename)
The imagepng function either sends an image to the browser or writes it to a file. If a
filename is provided, a PNG file is created. Otherwise, the image is sent directly to the
browser. This latter method is used in most of the examples in this section.
boolean imagepolygon(integer image, array points, integer
number, integer color)
The imagepolygon function behaves identically to the imagefilledpolygon function
with the exception that the polygon is not filled. The points argument is an array of
integers, two for each point of the polygon. A line will be drawn from each point in
succession and from the last point to the first point.