Merge pull request #2193 from SemanticsOS/lambdafu/libtiff-icc

Update info.icc_profile when using libtiff reader.
This commit is contained in:
wiredfool 2016-12-03 13:44:26 +00:00 committed by GitHub
commit 86606022c5
2 changed files with 14 additions and 5 deletions

View File

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

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