Commit 245b84f88 for imagemagick.org
commit 245b84f88b802eb362b1c4dfef791b4308edd9dd
Author: Dirk Lemstra <dirk@lemstra.org>
Date: Wed Dec 3 17:01:08 2025 +0100
Added define to make sure we don't always write a jpeg in a high bit depth (#8445)
diff --git a/coders/jpeg.c b/coders/jpeg.c
index 99388620d..76c0e8c99 100644
--- a/coders/jpeg.c
+++ b/coders/jpeg.c
@@ -2479,25 +2479,29 @@ static MagickBooleanType WriteJPEGImage_(const ImageInfo *image_info,
jpeg_info->image_height=(unsigned int) image->rows;
jpeg_info->input_components=3;
jpeg_info->data_precision=8;
-#if defined(C_LOSSLESS_SUPPORTED)
- if (image_info->compression == LosslessJPEGCompression)
+ option=GetImageOption(image_info,"jpeg:high-bit-depth");
+ if (IsStringTrue(option) != MagickFalse)
{
+#if defined(C_LOSSLESS_SUPPORTED)
+ if (image_info->compression == LosslessJPEGCompression)
+ {
#if defined(LIBJPEG_TURBO_VERSION_NUMBER) && LIBJPEG_TURBO_VERSION_NUMBER >= 3000090
- jpeg_info->data_precision=(int) image->depth;
+ jpeg_info->data_precision=(int) image->depth;
#else
- if (image->depth > 12)
- jpeg_info->data_precision=16;
- else if (image->depth > 8)
- jpeg_info->data_precision=12;
+ if (image->depth > 12)
+ jpeg_info->data_precision=16;
+ else if (image->depth > 8)
+ jpeg_info->data_precision=12;
#endif
- }
- else
+ }
+ else
#endif
- {
+ {
#if defined(MAGICKCORE_HAVE_JPEG12_WRITE_SCANLINES)
- if (image->depth > 8)
- jpeg_info->data_precision=12;
+ if (image->depth > 8)
+ jpeg_info->data_precision=12;
#endif
+ }
}
jpeg_info->in_color_space=JCS_RGB;
switch (image->colorspace)