Search code examples
imagemagickimagemagick-convert

Why did ImageMagick reduce my JPG quality severely when increasing saturation?


My command was convert imagename.jpeg -quality 100 -modulate 100,200 imagename-ImageMagick.jpeg and if you look at the Imgur gallery here:

https://i.sstatic.net/uxB9N.jpg

you can see that it has tons of JPG artefacts, to the point where the text is almost illegible. All I wanted to do was increase colour saturation.

Version info:

Version: ImageMagick 6.9.11-21 Q16 x86_64 2020-07-25 https://imagemagick.org Copyright: © 1999-2020 ImageMagick Studio LLC License: https://imagemagick.org/script/license.php Features: Cipher DPC Modules Delegates (built-in): bzlib djvu fftw fontconfig freetype gslib heic jbig jng jp2 jpeg lcms ltdl lzma openexr png ps raw tiff webp x xml zlib


Solution

  • Because when you increase saturation that much you make the existing JPEG artifacts more visible (in fact you make all the image problems more visible...). Adding saturation is increasing the tone differences, while the JPEG compression is based on the idea that the tone differences it creates are still below your perception, so increased saturation makes the existing and barely noticeable artifacts suddenly very visible.

    • -modulate 100,200 is a very aggressive setting, try something lighter
    • -quality 100 is pointless, you are just saving existing artifacts with a high accuracy.
    • maybe try a very light blur before increasing saturation.