Skip to content

Commit

Permalink
Merge pull request python-pillow#8347 from radarhere/boxblur
Browse files Browse the repository at this point in the history
  • Loading branch information
hugovk authored Sep 5, 2024
2 parents eaeda4a + 1270043 commit 965cb51
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Tests/test_box_blur.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ def test_color_modes() -> None:
box_blur(sample.convert("YCbCr"))


@pytest.mark.parametrize("size", ((0, 1), (1, 0)))
def test_zero_dimension(size: tuple[int, int]) -> None:
assert box_blur(Image.new("L", size)).size == size


def test_radius_0() -> None:
assert_blur(
sample,
Expand Down
3 changes: 3 additions & 0 deletions src/libImaging/BoxBlur.c
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,9 @@ ImagingBoxBlur(Imaging imOut, Imaging imIn, float xradius, float yradius, int n)
int i;
Imaging imTransposed;

if (imOut->xsize == 0 || imOut->ysize == 0) {
return imOut;
}
if (n < 1) {
return ImagingError_ValueError("number of passes must be greater than zero");
}
Expand Down

0 comments on commit 965cb51

Please sign in to comment.