Page 1 of 1

Thumbnails with target file size

Posted: 2009-11-14T07:57:16-07:00
by krumpi
Hi

I have been using quite a bit ImageMagick to create thumbnails both for personal use and in web applications. So first of all a big thanks to the ImageMagick team.

My question is that I can easily create thumbnails of a given size and then the file size is free but now I need to do the reverse operation. Given a max file size, create the biggest thumbnail possible. I need this for an iphone application that is used to control the Sonos sound system. The application limits the size of the thumbnails to 250K but I want to get the biggest size possible with that size contsraint.

Is this possible? I have looked at the docs of convert carefully but it seems not possible at the moment.

Any help will be appreciated

Carlos

Re: Thumbnails with target file size

Posted: 2009-11-14T08:39:50-07:00
by fmw42
I don't believe there is any direct method for doing that. The best I can suggest is to get the initial image size using

convert image -format %b info:

Then -resize or -thumbnail by whatever percent reduces that to 250K (testing with the same command above). Then iterate a little to fine tune to 250K. You can script that if you needed to decrement the percent near that initial percent until you get just below the desired 250K filesize.

But note that file size also depends upon compression. So for JPG, you can make a larger image by reducing the -quality.