cgohlke/imagecodecs

Cannot set JPEGXL effort lower than 3 in `jpegxl_encode`?

duncanterray opened this issue · 2 comments

Hi there!

I have been experimenting with jpegxl for lossless encoding, and noticed that setting the effort level below 3 does not seem to change the file size or time required to compress the image.

It looks like the effort is clamped between 3 and 9 with _default_value() here

int option_effort = _default_value(effort, 3, 3, 9) # 7 is too slow

libjpxl does detail different techniques used for lossless encoding, though levels below 3 are not supported for lossy encoding.

Effort Modular (lossless) VarDCT (lossy)
e1 fast-lossless, fixed YCoCg RCT, fixed ClampedGradient predictor, simple palette detection, no MA tree (one context for everything), Huffman, simple rle-only lz77
e2 global channel palette, fixed MA tree (context based on Gradient-error), ANS, otherwise same as e1
e3 same as e2 but fixed Weighted predictor and fixed MA tree with context based on WP-error only 8x8, basically XYB jpeg with ANS

Would it make sense to clamp to different effort ranges depending on the lossless encoding flag?

You are right, the effort should be clamped between 1 and 10. It'll be in the next release.

Thanks for looking into it! I'll keep an eye out for the next release.