Version: ImageMagick 6.9.7-4 Q16 x86_64 20170114 http://www.imagemagick.org
Copyright: © 1999-2017 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features: Cipher DPC Modules OpenMP
Delegates (built-in): bzlib djvu fftw fontconfig freetype jbig jng jpeg lcms lqr ltdl lzma openexr pangocairo png tiff wmf x xml zlib
Running on WSL (Bash on Windows)
I'm using convert like this:
convert pic1.jpg -filter Box -resize 120x160 -define jpeg:q-table=/path/to/xml out.jpg
but the custom quantization table is not being used (and it seems like a different table is used *not* the default one).
-define jpeg:q-table not respected
Re: -define jpeg:q-table not respected
I've tracked down the problem:
-define jpeg-qtable uses the standard jpeg library's jpeg_add_quant_table() function which scales the provided quantization table by the jpeg quality using the function: q value = round(provided_table_value * scale / 100).
There is no provision to define a verbatim quantization table.
-define jpeg-qtable uses the standard jpeg library's jpeg_add_quant_table() function which scales the provided quantization table by the jpeg quality using the function: q value = round(provided_table_value * scale / 100).
There is no provision to define a verbatim quantization table.
Last edited by elmo on 2019-05-15T04:02:08-07:00, edited 1 time in total.
Re: -define jpeg:q-table not respected
The solution is to use the ImageMagick flag -quality 50. The jpeg library converts this to a value of 100 via the function jpeg_quality_scaling(). This value of 100 will be passed to jpeg_add_quant_table(), negating the effect of the scaling (see the scaling function I posted earlier). I have not yet tested this, but it should work in theory.
IMHO this should be mentioned in the documentation. The expectation when providing a quantization table is that it will be used verbatim.
IMHO this should be mentioned in the documentation. The expectation when providing a quantization table is that it will be used verbatim.