You can set up a .htaccess file which will rewrite image_hello_john.jpg to image.php?txt1=hello&txt2=john :
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^image_([^/]+)_([^/]+).jpg?$ /image.php?txt1=$1&txt2=$2 [QSA,L]
</IfModule>
Not tested, but should be working. To write a text overlaying an image you can use the gd-libary which is usually part of the php installation, see the manual at
http://www.php.net/gd