Only deprecate setting of TIFF image sizes

This commit is contained in:
Andrew Murray 2018-09-30 15:08:35 +10:00
parent cea6ecfdbb
commit 6f44ae1d27
2 changed files with 21 additions and 0 deletions

View File

@ -69,6 +69,14 @@ class TestFileTiff(PillowTestCase):
self.assertEqual(str(e.exception),
"Not allowing setting of legacy api")
def test_size(self):
filename = "Tests/images/pil168.tif"
im = Image.open(filename)
def set_size():
im.size = (256, 256)
self.assert_warning(DeprecationWarning, set_size)
def test_xyres_tiff(self):
filename = "Tests/images/pil168.tif"
im = Image.open(filename)

View File

@ -1049,6 +1049,19 @@ class TiffImageFile(ImageFile.ImageFile):
"Return the current frame number"
return self.__frame
@property
def size(self):
return self._size
@size.setter
def size(self, value):
warnings.warn(
'Setting the size of a TIFF image direcly is deprecated, and will '
'be removed in a future version. Use the resize method instead.',
DeprecationWarning
)
self._size = value
def load(self):
if self.use_load_libtiff:
return self._load_libtiff()