Closed JackKelly closed 2 years ago
Right. This is mostly fixed in the development version, which introduces two additional parameters lossless
, and decodingspeed
JXL_BOOL option_lossless = lossless is None or bool(lossless)
int option_tier = _default_value(decodingspeed, 0, 0, 4)
The level
parameter is actually part of the imagecodecs encode API. Right now it is mapped to lossless
and tier
but maybe it's better mapped to effort
or distance
...
Awesome, thank you! Sorry for the silly question but how do I access the dev version of imagecodecs?
The level parameter is actually part of the imagecodecs encode API. Right now it is mapped to lossless and tier but maybe it's better mapped to effort or distance...
As you probably know, the cjxl
utility has a quality
setting (which takes a value between -inf and 100, where 100 is lossless). If the level
param in the imagecodecs
API is supposed to take a value up to 100 then maybe it's worth checking the cjxl
code to see how it maps from quality
to distance
etc?
AFAICT, the cjxl quality setting maps to fields in a private C++ struct. Those can't be set from C using the public API.
Thanks again for all your work on imagecodecs!
In
jpegxl_encode
,option_lossless
is set to True iflevel is None or level < 0
(line 160 of _jpegxl.pyx).The
level
argument tojpegxl_encode
is passed toJxlEncoderOptionsSetDecodingSpeed
which sets the decoding speed, not whether the image is lossless or not :slightly_smiling_face:. That is,level
is somewhat orthogonal to whetherlossless
mode should be engaged or not.An improvement might be to set
option_lossless
to True ifdistance
is0.0
. (See the docs for distance)(Also, would it be worth considering renaming
level
todecoding_speed
or something like that?)