diff --git a/PIL/TiffImagePlugin.py b/PIL/TiffImagePlugin.py index 3af38832d..69a216017 100644 --- a/PIL/TiffImagePlugin.py +++ b/PIL/TiffImagePlugin.py @@ -1010,9 +1010,6 @@ class TiffImageFile(ImageFile.ImageFile): # Section 14: Differencing Predictor self.decoderconfig = (self.tag_v2[PREDICTOR],) - if ICCPROFILE in self.tag_v2: - self.info['icc_profile'] = self.tag_v2[ICCPROFILE] - return args def load(self): @@ -1285,6 +1282,10 @@ class TiffImageFile(ImageFile.ImageFile): print("- unsupported data organization") raise SyntaxError("unknown data organization") + # Fix up info. + if ICCPROFILE in self.tag_v2: + self.info['icc_profile'] = self.tag_v2[ICCPROFILE] + # fixup palette descriptor if self.mode == "P": diff --git a/Tests/test_file_libtiff.py b/Tests/test_file_libtiff.py index 6e40d4b37..229c1e830 100644 --- a/Tests/test_file_libtiff.py +++ b/Tests/test_file_libtiff.py @@ -521,8 +521,16 @@ class TestFileLibTiff(LibTiffTestCase): except: self.fail("Should not get permission error here") - - + def test_read_icc(self): + with Image.open("Tests/images/hopper.iccprofile.tif") as img: + icc = img.info.get('icc_profile') + self.assertNotEqual(icc, None) + TiffImagePlugin.READ_LIBTIFF = True + with Image.open("Tests/images/hopper.iccprofile.tif") as img: + icc_libtiff = img.info.get('icc_profile') + self.assertNotEqual(icc_libtiff, None) + TiffImagePlugin.READ_LIBTIFF = False + self.assertEqual(icc, icc_libtiff) if __name__ == '__main__': unittest.main()