compress pictures to fit a 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
inigomena

compress pictures to fit a file size?

Post by inigomena »

Hi, as well as it is possible to resize files to fit a width and height, I'd like to be able to recompress JPG files to fit a certain file size if they are bigger than this size, is there an option to do this?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: compress pictures to fit a file size?

Post by fmw42 »

see the ">" symbol with -resize widthxheight>

http://www.imagemagick.org/script/comma ... php#resize
inigomena

Re: compress pictures to fit a file size?

Post by inigomena »

thanks, but I mean size in KB 8)
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: compress pictures to fit a file size?

Post by anthony »

File compression is a complex issue with so many factors results are not predicatable.

As such your only option is to use trial and error. that is resize and adjust quality until you get the image file size and other attributes you want.

PNG images (which is not lossy) has programs to try to find the minimal file size without image loss. JPEG is very different in this regard.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply