Update info.icc_profile when using libtiff reader.

This commit is contained in:
Marcus Brinkmann 2016-11-04 16:37:49 +01:00
parent 5aeb0ed972
commit 66de02685f
2 changed files with 14 additions and 5 deletions

View File

@ -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":

View File

@ -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()