thumbnail file size

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
djeyewater
Posts: 15
Joined: 2009-07-25T09:16:08-07:00
Authentication code: 8675309

thumbnail file size

Post by djeyewater »

With ImageMagick 6.5.9 when I resize an image to 500 pixels on the longest side and then resize this to a 150 pixels on the longest side thumbnail, the thumbnail has a much smaller file size than just resizing straight to a thumbnail without the intermediate 500px version.

For my test file I get a thumbnail file size of 4.6kB when first resizing to 500px. When resizing straight to thumbnail I get a file size of 15.5kB, quite a big difference.

I then tried the latest version of ImageMagick, 6.8.6-9. This doesn't have a big difference between the way the thumbnail is created - from a 500px file is 8.3kB vs. 8.5kB straight from the larger file. But this is worse performance than 6.5.9 when resizing to 500px before creating the thumbnail.

Code: Select all

~/apps/ImageMagick/bin/convert \
-filter Lanczos \
medium.jpg \
-set option:filter:filter Lanczos \
-set option:filter:blur 0.8 \
-resize 500x500 \
-quality 80 \
small.jpg

~/apps/ImageMagick/bin/convert \
medium.jpg \
-strip \
-thumbnail 150x150 \
thumb-from-medium.jpg
#6.8.6-9=8.5kB 6.5.9=15.5kB

~/apps/ImageMagick/bin/convert \
small.jpg \
-strip \
-thumbnail 150x150 \
thumb-from-small.jpg
#6.8.6-9=8.3kB 6.5.9=4.6kB
I've uploaded the test file I was working on here: http://www.iliveinabin.com/resize-test/medium.jpg

When I compiled 6.8.6-9 it didn't originally build with jpeg and tiff support, so I had to point it to jpeg and tiff libs, and I used libjpeg-turbo for the jpeg lib, which I guess might be what is causing the difference?

Does anyone know

1) Why I get such a big difference in the thumbnail file size with 6.5.9 depending on whether the image has been resized down to 500px or not?
2) Why the thumbnail file size is larger with 6.8.6-9 and how I can reduce it?

Thanks

Dave
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: thumbnail file size

Post by snibgo »

Medium has quality 98, so thumb-from-medium (in v6.8.6-9) also has quality 98.

You explicity make small of quality 80, hence thumb-from-small has quality 80.

As you may know, lower quality numbers give smaller file sizes (but lower quality).

If you want even smaller files, decrease the quality further.
snibgo's IM pages: im.snibgo.com
djeyewater
Posts: 15
Joined: 2009-07-25T09:16:08-07:00
Authentication code: 8675309

Re: thumbnail file size

Post by djeyewater »

Thanks for the answer, it seems obvious now you point it out! :oops:

Cheers

Dave
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: thumbnail file size

Post by snibgo »

Pleasure. Answers are often obvious when we know what they are!

Thanks for including your code, IM versions and sample image. Queries often don't include these vital ingredients, and diagnosis can be a long and drawn out process.
snibgo's IM pages: im.snibgo.com
Post Reply