mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-26 18:06:18 +03:00
Removed use of spaces in TIFF kwargs, deprecated in 2.7
This commit is contained in:
parent
badbff1b99
commit
41e492b026
|
@ -1378,11 +1378,6 @@ def _save(im, fp, filename):
|
||||||
(DATE_TIME, "date_time"),
|
(DATE_TIME, "date_time"),
|
||||||
(ARTIST, "artist"),
|
(ARTIST, "artist"),
|
||||||
(COPYRIGHT, "copyright")]:
|
(COPYRIGHT, "copyright")]:
|
||||||
name_with_spaces = name.replace("_", " ")
|
|
||||||
if "_" in name and name_with_spaces in im.encoderinfo:
|
|
||||||
warnings.warn("%r is deprecated; use %r instead" %
|
|
||||||
(name_with_spaces, name), DeprecationWarning)
|
|
||||||
ifd[key] = im.encoderinfo[name.replace("_", " ")]
|
|
||||||
if name in im.encoderinfo:
|
if name in im.encoderinfo:
|
||||||
ifd[key] = im.encoderinfo[name]
|
ifd[key] = im.encoderinfo[name]
|
||||||
|
|
||||||
|
|
|
@ -399,25 +399,6 @@ class TestFileTiff(PillowTestCase):
|
||||||
self.assertEqual(im.tag_v2[X_RESOLUTION], 72)
|
self.assertEqual(im.tag_v2[X_RESOLUTION], 72)
|
||||||
self.assertEqual(im.tag_v2[Y_RESOLUTION], 36)
|
self.assertEqual(im.tag_v2[Y_RESOLUTION], 36)
|
||||||
|
|
||||||
def test_deprecation_warning_with_spaces(self):
|
|
||||||
kwargs = {'resolution unit': 'inch',
|
|
||||||
'x resolution': 36,
|
|
||||||
'y resolution': 72}
|
|
||||||
filename = self.tempfile("temp.tif")
|
|
||||||
self.assert_warning(DeprecationWarning,
|
|
||||||
lambda: hopper("RGB").save(filename, **kwargs))
|
|
||||||
from PIL.TiffImagePlugin import X_RESOLUTION, Y_RESOLUTION
|
|
||||||
|
|
||||||
im = Image.open(filename)
|
|
||||||
|
|
||||||
# legacy interface
|
|
||||||
self.assertEqual(im.tag[X_RESOLUTION][0][0], 36)
|
|
||||||
self.assertEqual(im.tag[Y_RESOLUTION][0][0], 72)
|
|
||||||
|
|
||||||
# v2 interface
|
|
||||||
self.assertEqual(im.tag_v2[X_RESOLUTION], 36)
|
|
||||||
self.assertEqual(im.tag_v2[Y_RESOLUTION], 72)
|
|
||||||
|
|
||||||
def test_lzw(self):
|
def test_lzw(self):
|
||||||
# Act
|
# Act
|
||||||
im = Image.open("Tests/images/hopper_lzw.tif")
|
im = Image.open("Tests/images/hopper_lzw.tif")
|
||||||
|
@ -462,12 +443,12 @@ class TestFileTiff(PillowTestCase):
|
||||||
# however does.
|
# however does.
|
||||||
im = Image.new('RGB', (1, 1))
|
im = Image.new('RGB', (1, 1))
|
||||||
im.info['icc_profile'] = 'Dummy value'
|
im.info['icc_profile'] = 'Dummy value'
|
||||||
|
|
||||||
# Try save-load round trip to make sure both handle icc_profile.
|
# Try save-load round trip to make sure both handle icc_profile.
|
||||||
tmpfile = self.tempfile('temp.tif')
|
tmpfile = self.tempfile('temp.tif')
|
||||||
im.save(tmpfile, 'TIFF', compression='raw')
|
im.save(tmpfile, 'TIFF', compression='raw')
|
||||||
reloaded = Image.open(tmpfile)
|
reloaded = Image.open(tmpfile)
|
||||||
|
|
||||||
self.assertEqual(b'Dummy value', reloaded.info['icc_profile'])
|
self.assertEqual(b'Dummy value', reloaded.info['icc_profile'])
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user