Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raise error if TIFF dimension is a string #4103

Merged
merged 1 commit into from Sep 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Binary file added Tests/images/string_dimension.tiff
Binary file not shown.
5 changes: 5 additions & 0 deletions Tests/test_file_tiff.py
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
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