Commit 4d7581a3e for imagemagick.org
commit 4d7581a3e7052749763ebb8331fbc5702d0dddd1
Author: Dirk Lemstra <dirk@lemstra.org>
Date: Thu Dec 11 08:36:13 2025 +0100
Only allow setting the data_precision to values other then 16 and 12 when quality is lossless (>= 100).
diff --git a/coders/jpeg.c b/coders/jpeg.c
index 95a956d1a..45726236b 100644
--- a/coders/jpeg.c
+++ b/coders/jpeg.c
@@ -2483,16 +2483,17 @@ static MagickBooleanType WriteJPEGImage_(const ImageInfo *image_info,
if (IsStringTrue(option) != MagickFalse)
{
#if defined(C_LOSSLESS_SUPPORTED)
- if (image_info->quality == 100)
+ if (image_info->compression == LosslessJPEGCompression)
{
#if defined(LIBJPEG_TURBO_VERSION_NUMBER) && LIBJPEG_TURBO_VERSION_NUMBER >= 3000090
- jpeg_info->data_precision=(int) image->depth;
-#else
+ if (image_info->quality >= 100)
+ jpeg_info->data_precision=(int) image->depth;
+ else
+#endif
if (image->depth > 12)
jpeg_info->data_precision=16;
else if (image->depth > 8)
jpeg_info->data_precision=12;
-#endif
}
else
#endif