I have an application where I need to resize huge digital camera pictures down to 800x600 pixels. To do this I used ImageMagick's convert program which I feel gives much better quality than Python PIL. To reduce the file size I make sure I use the -strip option to convert but the really interesting question was what quality option should I use?

Goal: the image should be as small (in bytes) as possible without too reduced in picture quality.

To get the optimal picture quality of course the right option is -quality 100 and to get the smallest file size I should use -quality 10. To find out what quality setting to use I converted an original image with the following command 10 times:

convert vase.jpg -strip -quality <X> -resize 800x600 vase.quality-95.jpg

where <X> is the varying value between 10 to 100.

Plotting the filesize in a graph gives a pretty clear picture about the quality setting. Clearly the file size drastically increases when you go above 90%. My conclusion, use -quality 90.

ImageMagick conversion comparison

To see the result of each conversion, I've uploaded all output images so you can compare yourself.

UPDATE

I just realised that good old Gimp, sets the JPEG export quality to 85% by default. Could it be for the same reasons that this little analysis that I did?

Jan - 11 December 2006 [«« Reply to this]
And can you see much of a visual difference between 80% and 90%? I can't (flipping the tabs between them). That will save you another 1/3 of the size and is what I have always heard graphic designers use for web.
Peter Bengtsson - 12 December 2006 [«« Reply to this]
I can see a difference and I can see which one is worse than the other if challenged. But, it's only in a very particular area of the image.

I guess the lesson learnt is that it depends on the image and how important it is.
Jan - 12 December 2006 [«« Reply to this]
I'd challenge you if I had the time! I do see *a* difference, paging between them back and forth so that just some pixels change on my screen... now that's very hardcore way of comparing them in the first place. But I would be very hard pressed to tell which one is actually worse.

If they were side by side, it would get almost impossible... plus people don't look actively for the compression artifacts, just as they won't see every grammatic or stylistic mistake in the text, because they don't parse all the info, just the contours, significant bits here and there. Jeff brain stuff. 80% saves you 1/3 image bandwidth, I'd just bet on that.

But anyway, graphics is certainly none of my business, I never claimed otherwise ;)


Your email will never ever be published