image-processingimagemagick

Best options parameters for ImageMagick to compress JPEGs files to the minimal size without losing too much quality?


I want to compress a JPG image file with ImageMagick but can't get much difference in size. By default the output size is bigger than the input. I don't know why, but after adding some +profile options and setting down the quality I can get an smaller size but still similar to original.

Right now im using:

convert input.jpg +profile "*" -quality 70 output.jpg

But with this, the input image is 255kb, and the output image is 264kb. Is there any way to compress that image to 150kb at least? Is that possible? What ImageMagick options can I use?


Solution

  • I use always:

    in imagemagick should be

    convert -strip -interlace Plane -gaussian-blur 0.05 -quality 85% source.jpg result.jpg
    

    or in the newer version:

    magick source.jpg -strip -interlace Plane -gaussian-blur 0.05 -quality 85% result.jpg
    

    Source.

    From @Fordi in the comments (Don't forget to upvote him if you like this): If you dislike blurring, use -sampling-factor 4:2:0 instead. What this does is reduce the chroma channel's resolution to half, without messing with the luminance resolution that your eyes latch onto. If you want better fidelity in the conversion, you can get a slight improvement without an increase in filesize by specifying -define jpeg:dct-method=float - that is, use the more accurate floating point discrete cosine transform, rather than the default fast integer version.