Add the ability to automatically switch between 4:4:4 and 4:2:0 depending on the quality level
jrmuizel opened this issue · comments
Jeff Muizelaar commented
This makes a difference on https://afontenot.github.io/image-formats-comparison/#abandoned-factory&jpg=s&avif=s which defaults to using 4:4:4 which puts JPEG at a disadvantage at higher compression levels.
Even a flag that did something like q > 50 use 4:4:4, q < 50 use 4:2:0 would probably be a reasonable default. I can't imagine a scenario where it makes sense to use 4:4:4 for q < 50
Kornel commented
I agree that low-quality images encoded with 4:4:4 are wasting bits.
Do you mean subsampling should be done in the libjpeg API, or just the cjpeg
demo tool?
Jeff Muizelaar commented
Maybe just cjpeg to start
bat999 commented
Hi
Looks like this has been sorted :-)
cjpeg -version
mozjpeg version 4.1.1 (build 20220604)
cjpeg -quality 79 -outfile fooQ79.jpg foo.png
cjpeg -quality 80 -outfile fooQ80.jpg foo.png
cjpeg -quality 89 -outfile fooQ89.jpg foo.png
cjpeg -quality 90 -outfile fooQ90.jpg foo.png
exiftool -ver
12.42
exiftool fooQ79.jpg | grep "Sub Sampling"
Y Cb Cr Sub Sampling : YCbCr4:2:0 (2 2)
exiftool fooQ80.jpg | grep "Sub Sampling"
Y Cb Cr Sub Sampling : YCbCr4:2:2 (2 1)
exiftool fooQ89.jpg | grep "Sub Sampling"
Y Cb Cr Sub Sampling : YCbCr4:2:2 (2 1)
exiftool fooQ90.jpg | grep "Sub Sampling"
Y Cb Cr Sub Sampling : YCbCr4:4:4 (1 1
Jeff Muizelaar commented
Indeed, it happens here:
Line 565 in 08978e5