diff --git a/PIL/TiffImagePlugin.py b/PIL/TiffImagePlugin.py index 810f99e75..9bbcd03fe 100644 --- a/PIL/TiffImagePlugin.py +++ b/PIL/TiffImagePlugin.py @@ -1006,9 +1006,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): @@ -1281,6 +1278,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 2d1b33154..3a8c0b1c2 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()