Skip to content

Commit b9693a5

Browse files
authored
Merge pull request #4103 from radarhere/dimension
Raise error if TIFF dimension is a string
2 parents f228d0c + 9a977b9 commit b9693a5

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

Tests/images/string_dimension.tiff

483 Bytes
Binary file not shown.

Tests/test_file_tiff.py

+5
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,11 @@ def test_close_on_load_nonexclusive(self):
587587
im.load()
588588
self.assertFalse(fp.closed)
589589

590+
def test_string_dimension(self):
591+
# Assert that an error is raised if one of the dimensions is a string
592+
with self.assertRaises(ValueError):
593+
Image.open("Tests/images/string_dimension.tiff")
594+
590595

591596
@unittest.skipUnless(sys.platform.startswith("win32"), "Windows only")
592597
class TestFileTiffW32(PillowTestCase):

src/PIL/TiffImagePlugin.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1239,8 +1239,8 @@ def _setup(self):
12391239
print("- YCbCr subsampling:", self.tag.get(530))
12401240

12411241
# size
1242-
xsize = self.tag_v2.get(IMAGEWIDTH)
1243-
ysize = self.tag_v2.get(IMAGELENGTH)
1242+
xsize = int(self.tag_v2.get(IMAGEWIDTH))
1243+
ysize = int(self.tag_v2.get(IMAGELENGTH))
12441244
self._size = xsize, ysize
12451245

12461246
if DEBUG:

0 commit comments

Comments
 (0)