I appreciate the replies!
After reading a particular section in Sam's Teach Yourself PHP in 24 Hours, I've learned how to (almost) precisely center text on an image of any size.
I've tried quite a few different ways to add text to the bottom right and left corners of an image of any size but I haven't been able to figure that one out just yet. Anybody have a pointer or two on how I can do this?
edit: a friend showed me the light: imagestring()
The code to draw text on an images bottom left corner is as follows
<?php
$max_width = "125";
$max_height = "80";
$font = "Vera"; # Note the name & location here. Change as needed. Note the lack of the .ttf ext.
$text = "My text here";
# Set the enviroment variable for GD
putenv('GDFONTPATH=' . realpath('.'));
$img = imagecreatetruecolor($max_width, $max_height);
$red = imagecolorallocate($img, 255,0,0);
$textwidth = $max_width;
$textheight;
$fontsize = 15;
while ( true ) {
$box = imageTTFbbox( $fontsize, 0, $font, $text );
$textwidth = abs( $box[2] );
$textbodyheight = ( abs($box[7]) )-2;
if ( $textwidth < $max_width -20 )
break;
$fontsize--;
}
# Determine the approx. center point
/*
$pngXcenter = (int) ( $max_width/2 );
$pngYcenter = (int) ( $max_height/2 );
imageTTFtext( $img, $fontsize, 0,
(int) ($pngXcenter-($textwidth/2)),
(int) ($pngYcenter+(($textbodyheight)/2) ),
$red, $font, $text );
Uncomment this section if you want the text centered.
and comment out the imagestring function below
*/
imagestring($img, 5, 0, $max_height-$textbodyheight, $text, $red);
# Display the image
header("Content-type: image/png");
imagepng($img);
?>