You'll need GD installed. See http://www.boutell.com/GD/ for more information.
You said you're using a JPEG, so you'll need to use:
$im = imagecreatefromJPEG("/path/to/original.jpg");
Then, to add text, you can use either of two methods, one obviously being easier than the other:
imagestring(image,font,x,y,string,color)
imagettftext(image,size,angle,x,y,color,fontfile,text)
Color is supplied by allocating a RGB value:
$color = imagecolorallocate(image,r,g,b);
Now, output the final image:
imagejpeg($im);
In a whole, use something like this:
<?php
$im = imagecreatefromjpeg("original.jpg");
$white = imagecolorallocate($im,255,255,255);
$black = imagecolorallocate($im,0,0,0);
imagestring($im,1,10,100,"text at (10,100)",$black);
imagedestroy($im);
?>