Fix quantization table scaling when quality is applied to custom qtables

When both a custom quantization table and a quality value are provided,
the quantization table should be scaled using the JPEG quality scaling factor.
If quality is not explicitly set, the default base quality of 50 is used to preserve the original table.
This ensures consistent behavior when saving JPEGs with custom qtables.

Fixes part of the issue with applying 'quality' to 'qtables'.
This commit is contained in:
Kylian Ronfleux--Corail 2025-04-10 10:01:02 +00:00
parent e3c0ee6ae2
commit 13bffef91d

View File

@ -173,7 +173,7 @@ ImagingJpegEncode(Imaging im, ImagingCodecState state, UINT8 *buf, int bytes) {
/* Use custom quantization tables */
if (context->qtables) {
int i;
int quality = 100;
int quality = 50;
int last_q = 0;
if (context->quality != -1) {
quality = context->quality;