Skip to content

Commit

Permalink
Merge pull request #4103 from radarhere/dimension
Browse files Browse the repository at this point in the history
Raise error if TIFF dimension is a string
  • Loading branch information
radarhere authored Sep 30, 2019
2 parents f228d0c + 9a977b9 commit b9693a5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
Binary file added Tests/images/string_dimension.tiff
Binary file not shown.
5 changes: 5 additions & 0 deletions Tests/test_file_tiff.py
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,11 @@ def test_close_on_load_nonexclusive(self):
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):
Expand Down
4 changes: 2 additions & 2 deletions src/PIL/TiffImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -1239,8 +1239,8 @@ def _setup(self):
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:
Expand Down

0 comments on commit b9693a5

Please sign in to comment.