Thumbnails with target 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
krumpi

Thumbnails with target file size

Post 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
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Thumbnails with target file size

Post 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.
Post Reply