From 6309bfe92110be8b0cd0b588ce36ac13cd027c5c Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Tue, 16 Jun 2015 14:16:56 -0700 Subject: [PATCH] Support too long ExtraSamples. Some programs generate SamplesPerPixel entries in ExtraSamples instead of SamplesPerPixel-3, cf. #1227. This is a stopgap measure to support them. One could also decide to add generic code to always support having SamplesPerPixel entries (by dropping the first 3). --- PIL/TiffImagePlugin.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/PIL/TiffImagePlugin.py b/PIL/TiffImagePlugin.py index 24a401331..2fa9388eb 100644 --- a/PIL/TiffImagePlugin.py +++ b/PIL/TiffImagePlugin.py @@ -157,6 +157,7 @@ OPEN_INFO = { (II, 2, (1,), 1, (8, 8, 8, 8), (1,)): ("RGBA", "RGBa"), (II, 2, (1,), 1, (8, 8, 8, 8), (2,)): ("RGBA", "RGBA"), (II, 2, (1,), 1, (8, 8, 8, 8), (999,)): ("RGBA", "RGBA"), # Corel Draw 10 + (II, 2, (1, 1, 1, 1), 1, (8, 8, 8, 8), (1,)): ("RGBA", "RGBA"), # OSX Grab (II, 3, (1,), 1, (1,), ()): ("P", "P;1"), (II, 3, (1,), 2, (1,), ()): ("P", "P;1R"), (II, 3, (1,), 1, (2,), ()): ("P", "P;2"), @@ -185,10 +186,12 @@ OPEN_INFO = { (MM, 1, (3,), 1, (32,), ()): ("F", "F;32BF"), (MM, 2, (1,), 1, (8, 8, 8), ()): ("RGB", "RGB"), (MM, 2, (1,), 2, (8, 8, 8), ()): ("RGB", "RGB;R"), + (MM, 2, (1,), 1, (8, 8, 8, 8), ()): ("RGBA", "RGBA"), # missing ExtraSamples (MM, 2, (1,), 1, (8, 8, 8, 8), (0,)): ("RGBX", "RGBX"), (MM, 2, (1,), 1, (8, 8, 8, 8), (1,)): ("RGBA", "RGBa"), (MM, 2, (1,), 1, (8, 8, 8, 8), (2,)): ("RGBA", "RGBA"), (MM, 2, (1,), 1, (8, 8, 8, 8), (999,)): ("RGBA", "RGBA"), # Corel Draw 10 + (MM, 2, (1, 1, 1, 1), 1, (8, 8, 8, 8), (1,)): ("RGBA", "RGBA"), # OSX Grab (MM, 3, (1,), 1, (1,), ()): ("P", "P;1"), (MM, 3, (1,), 2, (1,), ()): ("P", "P;1R"), (MM, 3, (1,), 1, (2,), ()): ("P", "P;2"), @@ -705,9 +708,9 @@ class TiffImageFile(ImageFile.ImageFile): args = rawmode elif compression == "tiff_lzw": args = rawmode - if 317 in self.tag: + if PREDICTOR in self.tag: # Section 14: Differencing Predictor - self.decoderconfig = (self.tag[PREDICTOR][0],) + self.decoderconfig = (self.tag[PREDICTOR],) if ICCPROFILE in self.tag: self.info['icc_profile'] = self.tag[ICCPROFILE]