Skip to content

Commit

Permalink
Raise error if dimension is a string
Browse files Browse the repository at this point in the history
  • Loading branch information
radarhere committed Sep 30, 2019
1 parent 152ed62 commit 9a977b9
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 9a977b9

Please sign in to comment.