What format to use for thumbnails of uploaded images?

by Jerry   Last Updated June 29, 2015 13:01 PM - source

I'm working on a website where users can upload images. To ensure fast loading times on the image overview page, the application automatically creates a thumbnail of every image that is uploaded to the site.

Right now, I have it set so it will always create the thumbnail in the JPG format, mostly to make the files smaller. However, that approach has at least one drawback: JPG doesn't support transparency, so when a user uploads a PNG file that makes use of transparency, the thumbnail might look weird and the user might not be able to find the image in the gallery at a glance.

That led me to this question: why not just use the same format for the thumbnail as the original image? That way I can make sure that the thumbnail looks pretty much like the image the user uploaded. (Thinking about it, it could even support animated GIFs, though I'm not sure if that's a good idea). The downside of that approach would be that the file size might be higher, resulting in a worse user experience with the site.

As I'm writing this question, I'm beginning to feel like the second approach would be the one to prefer, but I'd still like to ask some other webmasters for input. What other technical reasons are there for using the same format for the thumbnail as the original image, or for simply using a fixed image format for all thumbnails?

Answers 1

Use the same format for thumbnail. The absolute difference between a resized jpg and a resized png/gif is too little to matter anyway, even thoug the percentual difference may still seem big. You may need to account for numbers as well, though. How many such png/gif thumbnails are you going to display on a single page at any time? If there are tens or hundreds, the overhead will add up and you need to make a tough decision. But if you have just a few tens of Kb extra, translated into something like less then 10%, the there's not much worry.

Lucian Davidescu
Lucian Davidescu
June 29, 2015 08:12 AM

Related Questions