I just finished doing something similar to this for a client:
Someone that wants to upload images submits the file via a php form. PHP then determines if the image is larger than a specified size, if it is, it is scaled and resampled. The client wants to have all the images IN the database, but I also have to keep a copy in the filesystem to make Flash happy. I store the image id, image title, description, human-readable-file-size, safe filename, image data, and mime-type in the database, and then use the safe filename to call the image from the filesystem for flash. I've also got a script that when passed an ID, regenerates the image from the database. Pulling images from the database is a little confusing at first, so I can help with that. Displaying random images is a cinch, and having an image of the day is also easy.
Before anyone asks, calling an image in flash like this doesn't work for me:
Code:
<img src="image.php?id=9">