https://bugs.gentoo.org/909834
https://hg.osdn.net/view/graphicsmagick/GM/rev/166bc6d3500d

# HG changeset patch
# User Bob Friesenhahn <bfriesen@GraphicsMagick.org>
# Date 1675522420 21600
# Node ID 166bc6d3500ddeb243c7c1b25ca0d9eade8e3b55
# Parent  8c82d3be78692071e2f74fb1b9543e9b8384d7cb
JPEG: Ignore C_LOSSLESS_SUPPORTED/D_LOSSLESS_SUPPORTED defined by JPEG-Turbo

--- a/coders/jpeg.c
+++ b/coders/jpeg.c
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003-2022 GraphicsMagick Group
+% Copyright (C) 2003-2023 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 % Copyright 1991-1999 E. I. du Pont de Nemours and Company
 %
@@ -954,7 +954,7 @@
     i;
 
   save_quality=0;
-#ifdef D_LOSSLESS_SUPPORTED
+#if !defined(LIBJPEG_TURBO_VERSION_NUMBER) && defined(D_LOSSLESS_SUPPORTED)
   if (image->compression==LosslessJPEGCompression)
     {
       save_quality=100;
@@ -1461,7 +1461,9 @@
     }
 #endif
 #if (JPEG_LIB_VERSION >= 61) && defined(D_PROGRESSIVE_SUPPORTED)
-#ifdef D_LOSSLESS_SUPPORTED
+#if !defined(LIBJPEG_TURBO_VERSION_NUMBER) && defined(D_LOSSLESS_SUPPORTED)
+  /* This code is based on a patch to IJG JPEG 6b, or somesuch.  Standard
+     library does not have a 'process' member. */
   image->interlace=
     jpeg_info.process == JPROC_PROGRESSIVE ? LineInterlace : NoInterlace;
   image->compression=jpeg_info.process == JPROC_LOSSLESS ?
@@ -2896,7 +2898,7 @@
   if ((image->compression == LosslessJPEGCompression) ||
       (quality > 100))
     {
-#if defined(C_LOSSLESS_SUPPORTED)
+#if !defined(LIBJPEG_TURBO_VERSION_NUMBER) && defined(C_LOSSLESS_SUPPORTED)
       if (quality < 100)
         ThrowException(&image->exception,CoderWarning,
                        LosslessToLossyJPEGConversion,(char *) NULL);
