mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-07-07 13:25:24 +03:00
Merge pull request #2087 from cskau/patch-1
Fixes TIFFImagePlugin ICC color profile saving.
This commit is contained in:
commit
e0b957240b
|
@ -1362,10 +1362,10 @@ def _save(im, fp, filename):
|
||||||
ifd[key] = im.tag_v2[key]
|
ifd[key] = im.tag_v2[key]
|
||||||
ifd.tagtype[key] = im.tag_v2.tagtype[key]
|
ifd.tagtype[key] = im.tag_v2.tagtype[key]
|
||||||
|
|
||||||
# preserve ICC profile (should also work when saving other formats
|
# preserve ICC profile (should also work when saving other formats
|
||||||
# which support profiles as TIFF) -- 2008-06-06 Florian Hoech
|
# which support profiles as TIFF) -- 2008-06-06 Florian Hoech
|
||||||
if "icc_profile" in im.info:
|
if "icc_profile" in im.info:
|
||||||
ifd[ICCPROFILE] = im.info["icc_profile"]
|
ifd[ICCPROFILE] = im.info["icc_profile"]
|
||||||
|
|
||||||
for key, name in [(IMAGEDESCRIPTION, "description"),
|
for key, name in [(IMAGEDESCRIPTION, "description"),
|
||||||
(X_RESOLUTION, "resolution"),
|
(X_RESOLUTION, "resolution"),
|
||||||
|
|
|
@ -499,5 +499,21 @@ class TestFileTiff(PillowTestCase):
|
||||||
with Image.open(mp) as im:
|
with Image.open(mp) as im:
|
||||||
self.assertEqual(im.n_frames, 3)
|
self.assertEqual(im.n_frames, 3)
|
||||||
|
|
||||||
|
def test_saving_icc_profile(self):
|
||||||
|
# Tests saving TIFF with icc_profile set.
|
||||||
|
# At the time of writing this will only work for non-compressed tiffs
|
||||||
|
# as libtiff does not support embedded ICC profiles, ImageFile._save(..)
|
||||||
|
# however does.
|
||||||
|
im = Image.new('RGB', (1, 1))
|
||||||
|
im.info['icc_profile'] = 'Dummy value'
|
||||||
|
|
||||||
|
# Try save-load round trip to make sure both handle icc_profile.
|
||||||
|
tmpfile = self.tempfile('temp.tif')
|
||||||
|
im.save(tmpfile, 'TIFF', compression='raw')
|
||||||
|
reloaded = Image.open(tmpfile)
|
||||||
|
|
||||||
|
self.assertEqual(b'Dummy value', reloaded.info['icc_profile'])
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user