Commit b8d0cd4ef for imagemagick.org
commit b8d0cd4ef084c86b26c21315b9b88dc4a40ec568
Author: Dirk Lemstra <dirk@lemstra.org>
Date: Thu Apr 9 14:27:23 2026 +0200
Fix incorrect orientation of JPEG compressed TIFF images (dlemstra/Magick.NET/issues/1991)
diff --git a/coders/tiff.c b/coders/tiff.c
index 7c9bda2ee..f811c0a8e 100644
--- a/coders/tiff.c
+++ b/coders/tiff.c
@@ -965,14 +965,18 @@ static TIFFMethodType GetJPEGMethod(Image* image,TIFF *tiff,uint16 photometric,
length;
/*
- Only support 8 bit for now.
- */
- if ((photometric != PHOTOMETRIC_SEPARATED) || (bits_per_sample != 8) ||
- (samples_per_pixel != 4))
- return(ReadGenericMethod);
- /*
- Search for Adobe APP14 JPEG marker.
+ Non-CMYK JPEG TIFFs can be decoded with the strip method when 8-bit,
+ fall back to the generic method for other bit depths.
*/
+ if (photometric != PHOTOMETRIC_SEPARATED)
+ {
+ if (bits_per_sample != 8)
+ return(ReadGenericMethod);
+ return(ReadStripMethod);
+ }
+ /* Only 8-bit and 4-sample are supported for the APP14 marker probe */
+ if ((bits_per_sample != 8) || (samples_per_pixel != 4))
+ return(ReadStripMethod);
if (!TIFFGetField(tiff,TIFFTAG_STRIPOFFSETS,&value) || (value == NULL))
return(ReadStripMethod);
position=TellBlob(image);