Creation of images with a given maximum 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
User avatar
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Post by anthony »

IM provides no such method.

The problem is that IM has no way of known just how big the final image size on disk will be given the various compressions, quality, image size, color space, and file format the image is actually using. It is imposible to pre-determine, except posibly as a guess-timate, or actually doing it.

All image programs have this problem and none have an exact solution, eacept via guessing and hoping for the best.

The only way is to try writting the file either to disk, or in an API to a 'blob', then get IM to fiddle the parameters, and try again until you get the size you want.

PNG format has a program called 'pngcrush' that trys saving a png image in various way until it gets the smallest version posible, Of course png is loss-less so that is fine.

JPG has no such program available, though it would be easy to write one to find the best JPEG quailty for a given size, from some loss-less image input.

Perhaps someone can write a perlMagick API to do this for you.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
Post Reply