Not going to create the whole thing for you atm...buuut, as a somewhat psuedo-code example...
//create the image from file
//(see manual for different functions)
$image = @imagecreatefromjpeg("pic.jpg");
if ( $image )
{
//create the text color
$txtColor = imagecolorallocate($image, 0, 0, 255);
//write the text
imagestring($image, 5, 0, 0, "Hosted by Weblogimages.com!", $txtColor);
header ( "Content-type: image/jpg" );
imagejpeg($image);
}
Now, you'll have to play around with it a lot more, but that's the general idea. Hope this helps!