Just to add as an idea for people that come across this:
You can have your image live as part of a php script: You ask for the image in your html/php the normal way, except you use a php file: <img src="name.php">
In name.php you do whatever php related you need to be done. After that, you just read the image and spit it out to the screen, readfile('image.jpg');