views:

76

answers:

3

Hi.

Imagine you have a classifieds website...

When searching ads you want image thumbnails of the "real" image which displays in its real size after clicking the ad...

Would it be faster to create the thumbnails per search, or create the thumbnails on and then just display them?

Storage is not a problem on my server...

Thanks

A: 

Assuming that the images are of a fixed size, then it is better to create them upfront. Otherwise you have at minimum a per-request check for existence per image. If they are created ahead of time, we assume that the images exist.

JBland
A: 

I would create the thumbnail once the original image has been uploaded, this way there's no slowdown when the person's page is first hit.

However, lately I've been using an image resize script from Shifting Pixel (http://shiftingpixel.com/2008/03/03/smart-image-resizer/). It creates a resized version on the fly, and caches it, so subsequent hits to the page will use the cached version. This could be useful if you don't want to create the thumbnail yourself.

Arms
A: 

Creating the thumbnail dynamically is your best bet, especially considering you'll probably reformat the search results at some point and will likely end up choosing a different size for the thumbnail. If you only have a thumbnail thats 150x150 pixels but after a redesign of the results page you want thumbnails to be a little larger, say 300x300, you'll have to regenerate all the thumbnails again. If you create them dynamically on request you can just alter your resize script to give you thumbnails that are 300x300.

Jacob Ewald