So I got a VPS setup and am intending to use it to host my albums.
Right now I'm trying to figure out how to handle multiple sizes of the same image.
A couple of design considerations:
Want to limit the amount of of thumbnails so they don't eat up disk space.
Don't want to use width and height attributes to fake thumbnails (eats up bandwidth and makes the user wait longer).
Easy to do.
So given the first part I think it should be a "on the fly" thing. However, general caching rules apply in that if it is requested once it is liable to be requested again in the near future.
What I came up with (with some ideas stolen from Google

) is this:
When an image is added to the system it goes into a separate and unique directory (added benefit of avoiding name clashes). Then to get a thumbnail a request is made to: dir/sXYZ/name where XYZ is the size. The size is a single number for the long dimension, that way I can preserve the ratio.
If the thumbnail doesn't exist it'll trigger the custom 404 handler which then figures out if the image they are requesting a thumbnail from is valid, if the thumbnail is smaller then the original, and if so resizes the images and writes the thumbnail. It'll also create the subdirectory if required. It then sends back a 302 with the Location set for the thumbnail along with a noretry query parameter so that it doesn't get stuck in a loop of 404s.
The reason for the subdirectories for each size is so that the filename remains the same.
I haven't figured out how I'm gonna go about cleaning up the thumbnails yet. It might just end up being a nightly cron that just kills them all.
Anyone have any comments or other ideas?