mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-14 11:26:27 +03:00
input parameter filtering
This commit is contained in:
parent
ff7962c3be
commit
95a25a0d82
|
@ -8,11 +8,29 @@ class TestImagingCoreResize(PillowTestCase):
|
||||||
xsize = 0x100000008 // 4
|
xsize = 0x100000008 // 4
|
||||||
ysize = 1000 # unimportant
|
ysize = 1000 # unimportant
|
||||||
try:
|
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")
|
self.fail("Resize should raise MemoryError on invalid xsize")
|
||||||
except MemoryError:
|
except MemoryError:
|
||||||
self.assertTrue(True, "Should raise 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__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
|
@ -1532,6 +1532,10 @@ _resize(ImagingObject* self, PyObject* args)
|
||||||
|
|
||||||
imIn = self->image;
|
imIn = self->image;
|
||||||
|
|
||||||
|
if (xsize < 1 || ysize < 1) {
|
||||||
|
return ImagingError_ValueError("height and width must be > 0");
|
||||||
|
}
|
||||||
|
|
||||||
if (imIn->xsize == xsize && imIn->ysize == ysize) {
|
if (imIn->xsize == xsize && imIn->ysize == ysize) {
|
||||||
imOut = ImagingCopy(imIn);
|
imOut = ImagingCopy(imIn);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user