Annotation requires a ttf font which can be a path URL or a site URL. You can create shadows, carve text, wave text etc. but let's do a simple annotate.

Set Font and Text
First we set the font and the text we want. If you want more than one line of text, be sure to name each line uniquely..i.e. $text2; $text3...etc.

$text = 'Sally';

$font = 'Admiral.ttf';

Size and Placement
This line sets the size(40); the angle of rotation if you desire(0); the x-axis placement(20); and the y-axis placement(50).

imagettftext($im, 40, 0, 20, 50, $black, $font, $text);

By putting two with slightly different placements, you can get a shadow effect....

This creates a shadow right and down...

imagettftext($im, 40, 0, 22, 52, $black, $font, $text);

imagettftext($im, 40, 0, 20, 50, $maroon, $font, $text);

This creates a shadow left and up...

imagettftext($im, 40, 0, 18, 48, $black, $font, $text);

imagettftext($im, 40, 0, 20, 50, $maroon, $font, $text);

It has been found that the font size in GD differs from other software such as Image Magick, Photoshop, and the C# Library. The font size in GD is five bigger than the others.

This zip file contains the original php script and font to produce what you see on this page. Let your imagination go and have some fun...!!!

GD BasicsHome