Skip to content

Commit

Permalink
Merge pull request #91 from radarhere/invalid-box-blur-filter
Browse files Browse the repository at this point in the history
  • Loading branch information
hugovk committed Jan 11, 2023
2 parents 08c7b17 + 173b65d commit d504d2a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Tests/test_image_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,3 +179,9 @@ def test_consistency_5x5(mode):
def test_invalid_box_blur_filter():
with pytest.raises(ValueError):
ImageFilter.BoxBlur(-2)

im = hopper()
box_blur_filter = ImageFilter.BoxBlur(2)
box_blur_filter.radius = -2
with pytest.raises(ValueError):
im.filter(box_blur_filter)
3 changes: 3 additions & 0 deletions src/libImaging/BoxBlur.c
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,9 @@ ImagingBoxBlur(Imaging imOut, Imaging imIn, float radius, int n) {
if (n < 1) {
return ImagingError_ValueError("number of passes must be greater than zero");
}
if (radius < 0) {
return ImagingError_ValueError("radius must be >= 0");
}

if (strcmp(imIn->mode, imOut->mode) || imIn->type != imOut->type ||
imIn->bands != imOut->bands || imIn->xsize != imOut->xsize ||
Expand Down

0 comments on commit d504d2a

Please sign in to comment.