mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-26 09:14:27 +03:00
unsupported modes
This commit is contained in:
parent
008c1c88e2
commit
1d1f3be27a
|
@ -32,6 +32,19 @@ class TestImageReduce(PillowTestCase):
|
|||
with self.assertRaises(ValueError):
|
||||
im.reduce((0, 10))
|
||||
|
||||
def test_unsupported_modes(self):
|
||||
im = Image.new("P", (10, 10))
|
||||
with self.assertRaises(ValueError):
|
||||
im.reduce(3)
|
||||
|
||||
im = Image.new("1", (10, 10))
|
||||
with self.assertRaises(ValueError):
|
||||
im.reduce(3)
|
||||
|
||||
im = Image.new("I;16", (10, 10))
|
||||
with self.assertRaises(ValueError):
|
||||
im.reduce(3)
|
||||
|
||||
def get_image(self, mode):
|
||||
bands = [self.gradients_image]
|
||||
for _ in ImageMode.getmode(mode).bands[1:]:
|
||||
|
|
|
@ -963,6 +963,12 @@ ImagingReduce(Imaging imIn, int xscale, int yscale)
|
|||
ImagingSectionCookie cookie;
|
||||
Imaging imOut = NULL;
|
||||
|
||||
if (strcmp(imIn->mode, "P") == 0 || strcmp(imIn->mode, "1") == 0)
|
||||
return (Imaging) ImagingError_ModeError();
|
||||
|
||||
if (imIn->type == IMAGING_TYPE_SPECIAL)
|
||||
return (Imaging) ImagingError_ModeError();
|
||||
|
||||
imOut = ImagingNewDirty(imIn->mode,
|
||||
(imIn->xsize + xscale - 1) / xscale,
|
||||
(imIn->ysize + yscale - 1) / yscale);
|
||||
|
|
Loading…
Reference in New Issue
Block a user