Which is the smarter way to do things..

Should I create a thumbnail script that resizes and crops the images so they are uniform when I create and upload a gallery?

Or

Should I run a script when the page loads that resizes and crops the images so they are uniform?

What are the pros and cons of the two?

Recommended Answers

All 2 Replies

The biggest con I can think of for the first method would be the volume of files you potentially could end up with as you would end up with hosting 2 files for every 1 you had. This has the potential of being rather costly on hosting space as well as managing the files. Most of the time you add 1 or 2 files here and there, given 2-3 months you could end up uploading 200-300+ files which would result in 400-600 files being added to the server. The obvious pro side would be that the thumbnails already exist and just have to bee downloaded, quick, clean, easy.

However, where scripts save on hosting space and eases the burden of file management (e.g. keeping track of which files are associated with each other, renaming etc...), they can be problematic as when a user visits a page of thumbnails, they will have to wait until each thumbnail is processed before proceeding. This will be an arbitrary amount of time based on how heavy the server load is and or how much processing power the host has alloted to you. The pro side to this could be that you could randomize the location of the thumbnails taken from the picture.

As a final comment and thought, this might be a bit on the conformist side but when you go to other sites that use thumbnails, what method are they using? Though I say to try out both methods and go with whichever you are comfortable or prefer dealing with.

Nyight already gave you a good explanation, I just want to add my two cents. I use phpThumb to do this and it is actually a bit of both. Thumbnails are created if they do not yet exist, or recreated if the file has changed. It also supports caching, so if the browser requests the same file again, it will send a 304 Not Modified. My galleries are not that large, so server processing versus storage is no real issue for me. However, most web-hosts would rather have the storage than the increase in server CPU usage.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.