Merge pull request #4103 from radarhere/dimension

Raise error if TIFF dimension is a string
This commit is contained in:
Andrew Murray 2019-09-30 21:26:53 +10:00 committed by GitHub
commit b9693a51c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 2 deletions

Binary file not shown.

View File

@ -587,6 +587,11 @@ class TestFileTiff(PillowTestCase):
im.load()
self.assertFalse(fp.closed)
def test_string_dimension(self):
# Assert that an error is raised if one of the dimensions is a string
with self.assertRaises(ValueError):
Image.open("Tests/images/string_dimension.tiff")
@unittest.skipUnless(sys.platform.startswith("win32"), "Windows only")
class TestFileTiffW32(PillowTestCase):

View File

@ -1239,8 +1239,8 @@ class TiffImageFile(ImageFile.ImageFile):
print("- YCbCr subsampling:", self.tag.get(530))
# size
xsize = self.tag_v2.get(IMAGEWIDTH)
ysize = self.tag_v2.get(IMAGELENGTH)
xsize = int(self.tag_v2.get(IMAGEWIDTH))
ysize = int(self.tag_v2.get(IMAGELENGTH))
self._size = xsize, ysize
if DEBUG: