mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-26 18:06:18 +03:00
input parameter filtering
This commit is contained in:
parent
ff7962c3be
commit
95a25a0d82
|
@ -8,11 +8,29 @@ class TestImagingCoreResize(PillowTestCase):
|
|||
xsize = 0x100000008 // 4
|
||||
ysize = 1000 # unimportant
|
||||
try:
|
||||
im.im.resize((xsize, ysize), Image.LINEAR) # any resampling filter will do here
|
||||
# any resampling filter will do here
|
||||
im.im.resize((xsize, ysize), Image.LINEAR)
|
||||
self.fail("Resize should raise MemoryError on invalid xsize")
|
||||
except MemoryError:
|
||||
self.assertTrue(True, "Should raise MemoryError")
|
||||
|
||||
def test_invalid_size(self):
|
||||
im = hopper()
|
||||
|
||||
im.resize((100,100))
|
||||
self.assertTrue(True, "Should not Crash")
|
||||
|
||||
try:
|
||||
im.resize((-100,100))
|
||||
self.fail("Resize should raise a value error on x negative size")
|
||||
except ValueError:
|
||||
self.assertTrue(True, "Should raise ValueError")
|
||||
|
||||
try:
|
||||
im.resize((100,-100))
|
||||
self.fail("Resize should raise a value error on y negative size")
|
||||
except ValueError:
|
||||
self.assertTrue(True, "Should raise ValueError")
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
|
@ -1532,6 +1532,10 @@ _resize(ImagingObject* self, PyObject* args)
|
|||
|
||||
imIn = self->image;
|
||||
|
||||
if (xsize < 1 || ysize < 1) {
|
||||
return ImagingError_ValueError("height and width must be > 0");
|
||||
}
|
||||
|
||||
if (imIn->xsize == xsize && imIn->ysize == ysize) {
|
||||
imOut = ImagingCopy(imIn);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user