-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for 16-bit precision JPEG quantization values #4918
Conversation
Do you think Pillow needs its own These 16-bit precision quantization values are apparently something you'd normally only get in low quality JPEGs, and they are optional in the standard according to https://github.com/libjpeg-turbo/libjpeg-turbo/blob/6d8caa9f88184ad1698e91c94b37acb9506dacf0/usage.txt#L123 so some decoders may not support them. Even with libjpeg (and Pillow) will emit the JTRC_16BIT_TABLES warning ("Caution: quantization tables are too coarse for baseline JPEG") when the only thing that prevents a JPEG from being "baseline" is the 16-bit quantization values. |
Are you able to add tests that fail without your changes and pass with them? |
Don't force JPEG quantization to be baseline-compatible Quantization values will not be limited to values 1..255 and may be 16 bits if needed. This may cause compatibility issues.
16-bit quantization tables can appear at quality values below about 25. These may cause compatibility problems. Maintain baseline compatibility and avoid confusing users with warning messages.
I can add tests... |
I've made one change to my earlier implementation. When using the
So my fix will only create 16-bit values if you specify your own tables or if you use I also ran into #4962 while writing the tests. I can fix that one too if you agree that it needs fixing. |
This only adds the support on the Python side. This won't really do anything without further changes to forward this to the C code.
This is a partial fix for #4825.
I've changed the
TRUE
toFALSE
inPillow/src/libImaging/JpegEncode.c
Line 164 in 2e029d9
To fully address the issue I guess the
qtables
property of theJPEGENCODERSTATE
needs to be expanded to include the precision info so we can tell the encoder which format to use.