mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-25 17:36:18 +03:00
Merge pull request #2111 from anntzer/save-tiff-resolution-when-originally-missing-entry
Fix saving originally missing TIFF tags.
This commit is contained in:
commit
8ed63793bf
|
@ -1359,7 +1359,7 @@ def _save(im, fp, filename):
|
||||||
IPTC_NAA_CHUNK, PHOTOSHOP_CHUNK, XMP):
|
IPTC_NAA_CHUNK, PHOTOSHOP_CHUNK, XMP):
|
||||||
if key in im.tag_v2:
|
if key in im.tag_v2:
|
||||||
ifd[key] = im.tag_v2[key]
|
ifd[key] = im.tag_v2[key]
|
||||||
ifd.tagtype[key] = im.tag_v2.tagtype.get(key, None)
|
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
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
import logging
|
import logging
|
||||||
|
from io import BytesIO
|
||||||
import struct
|
import struct
|
||||||
|
|
||||||
from helper import unittest, PillowTestCase, hopper, py3
|
from helper import unittest, PillowTestCase, hopper, py3
|
||||||
|
@ -103,6 +104,15 @@ class TestFileTiff(PillowTestCase):
|
||||||
im._setup()
|
im._setup()
|
||||||
self.assertEqual(im.info['dpi'], (71., 71.))
|
self.assertEqual(im.info['dpi'], (71., 71.))
|
||||||
|
|
||||||
|
def test_save_setting_missing_resolution(self):
|
||||||
|
from PIL.TiffImagePlugin import X_RESOLUTION, Y_RESOLUTION
|
||||||
|
b = BytesIO()
|
||||||
|
Image.open("Tests/images/10ct_32bit_128.tiff").save(
|
||||||
|
b, format="tiff", resolution=123.45)
|
||||||
|
im = Image.open(b)
|
||||||
|
self.assertEqual(float(im.tag_v2[X_RESOLUTION]), 123.45)
|
||||||
|
self.assertEqual(float(im.tag_v2[Y_RESOLUTION]), 123.45)
|
||||||
|
|
||||||
def test_invalid_file(self):
|
def test_invalid_file(self):
|
||||||
invalid_file = "Tests/images/flower.jpg"
|
invalid_file = "Tests/images/flower.jpg"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user