URL-Based Thumbnail Generation

I am currently have a 'products' table that has a ":has_many"
relationship with a 'photos' table.

I am uploading photos to accompany products. Right now, I upload the
photo, save the metadata to the 'photos' table and the image to the
filesystem. Then, I direct a url from within the products display
pages to point to a thumbnail generator. For example, /products,
would display all the products with the product's associated images.
The images would be formed by <img src="/photos/thumbnailer/?
height=200&width=200 ?>. The '/thumbnailer' action then generates,
saves (based on sizes), and displays the thumbnail of the uploaded
file. If another request comes in for the same page, the saved
thumbnails are displayed and the '/thumbnailer' action does not
generate any new images. Thus, there is heavy overhead only on the
first request. I like this because if I ever wish to change the
layout of the site, all I have to do is change the url to meet the new
parameters.

However, I have seen that most of the plugins that help with file
uploads tend to generate thumbnails at the time of file uploads. For
example, maybe a 'small', 'medium', and 'large' thumbnail are
generated and served up throughout the site. However, this seems like
more of a hassle to update if the design requirements change.

Since I am a new programmer, I am sure there are good reasons why
others do it differently (like many of the plugins). Any thoughts?
What drawbacks am I missing with my method?

Thanks

Andrew

Doing it your way would mean that you have to keep track of whether a
thumbnail has been generated or not (extra complexity)
You would also have to run your image request through the Rails stack
instead of just serving the image from the file system.

By processing the images at upload, you now have images that can be
quickly served from the file system without going through Rails for
checking first.

If you want to change the layout of your site, you can run a batch
process that re-processes all the images to the new dimensions. A
number of the plugins allow for reprocessing
Photo.find_in_batches.each do |batch|
  batch.each do |photo|
    photo.reprocess! #<- psuedo method
  end
end

Andrew Timberlake
http://ramblingsonrails.com

http://MyMvelope.com - The SIMPLE way to manage your savings

Thanks so much for the feedback. Very helpful. I will be switching
my ways...

Andrew