6

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

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

For a sample file:

  • If i don't specify quality 75, i get a 40Kb file
  • If i specify quality 75, i get a 36 kb file and it looks awful
  • The same file resized in photoshop is < 10 kb - and it looks awesome!

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?

Marius
  • 3,976
  • 5
  • 37
  • 52

1 Answers1

2

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.

Tomasz Gandor
  • 8,235
  • 2
  • 60
  • 55