Marius
Marius

Reputation: 4016

ImageMagick JPEG quality/size

I'm using the following command to generate a thumbnail:

mogrify -resize 128x128 -quality 75 "some thumb file"

For a sample file:

Is it possible to use imagemagick to resize a thumbnail to such a low filesize so that the resulting image wouldn't suck? Maybe i'm missing some other setting here?

Upvotes: 6

Views: 7039

Answers (1)

Tomasz Gandor
Tomasz Gandor

Reputation: 8833

What you've got without -quality was probably quality 92, or the quality of the input image (which, if large, could look OK despite low quality setting).

https://imagemagick.org/script/command-line-options.php#quality

The JPEG quality depends on mostly 2 things:

  • the used Quantization Matrix (or separate QMs: one for Y, and other for Cb and Cr)
  • whether there is chroma subsampling, e.g. the image uses one 8x8 block (coding unit) to store color information for a 16x16 (in 4:2:0 case) block of pixels

Your preferred quality, 90, is the lowest for which there is no subsampling. It may be that for small images, like thumbnails, high res color information is important.

Final note - Photoshop has it's own choice of quantization matrices for their "quality" settings. These are different than mogrify's and libjpeg's in general. You should find the correct quality level in mogrify, and not rely on the number from Photoshop.

If you want to emulate the PS compression, you can get their QM-s:

$ djpeg -v -v saved_by_photoshop.jpg >/dev/null

And then compress some image using these matrices. cjpeg can do it using -qtables file_with_QMs.txt.

Upvotes: 2

Related Questions