Allow 0 size images, Fixes #2259

This commit is contained in:
wiredfool 2016-11-29 19:25:49 +00:00
parent 41c97af15c
commit 69bea50810
2 changed files with 7 additions and 3 deletions

View File

@ -1994,8 +1994,8 @@ def _check_size(size):
raise ValueError("Size must be a tuple")
if len(size) != 2:
raise ValueError("Size must be a tuple of length 2")
if size[0] <= 0 or size[1] <= 0:
raise ValueError("Width and Height must be > 0")
if size[0] < 0 or size[1] < 0:
raise ValueError("Width and Height must be => 0")
return True

View File

@ -256,7 +256,11 @@ class TestImage(PillowTestCase):
with self.assertRaises(ValueError):
Image.new('RGB', (0,)) # Tuple too short
with self.assertRaises(ValueError):
Image.new('RGB', (0,0)) # w,h <= 0
Image.new('RGB', (-1,-1)) # w,h < 0
# this should pass with 0 sized images, #2259
im = Image.new('L', (0, 0))
self.assertEqual(im.size, (0, 0))
self.assertTrue(Image.new('RGB', (1,1)))
# Should pass lists too