Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
unsupported modes
  • Loading branch information
homm committed Dec 1, 2019
commit 1d1f3be27acd50fc4b8184707d7f6223a3fde97f
13 changes: 13 additions & 0 deletions 13 Tests/test_image_reduce.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,19 @@ def test_args(self):
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:]:
Expand Down
6 changes: 6 additions & 0 deletions 6 src/libImaging/Reduce.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.