mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-26 01:46:18 +03:00
Allow 0 size images, Fixes #2259
This commit is contained in:
parent
41c97af15c
commit
69bea50810
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user