mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-26 01:46:18 +03:00
Raise ValueError for BoxBlur filter with negative radius
This commit is contained in:
parent
50f7888e3a
commit
08c7b17e23
|
@ -24,6 +24,7 @@ from .helper import assert_image_equal, hopper
|
||||||
ImageFilter.ModeFilter,
|
ImageFilter.ModeFilter,
|
||||||
ImageFilter.GaussianBlur,
|
ImageFilter.GaussianBlur,
|
||||||
ImageFilter.GaussianBlur(5),
|
ImageFilter.GaussianBlur(5),
|
||||||
|
ImageFilter.BoxBlur(0),
|
||||||
ImageFilter.BoxBlur(5),
|
ImageFilter.BoxBlur(5),
|
||||||
ImageFilter.UnsharpMask,
|
ImageFilter.UnsharpMask,
|
||||||
ImageFilter.UnsharpMask(10),
|
ImageFilter.UnsharpMask(10),
|
||||||
|
@ -173,3 +174,8 @@ def test_consistency_5x5(mode):
|
||||||
Image.merge(mode, source[: len(mode)]).filter(kernel),
|
Image.merge(mode, source[: len(mode)]).filter(kernel),
|
||||||
Image.merge(mode, reference[: len(mode)]),
|
Image.merge(mode, reference[: len(mode)]),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def test_invalid_box_blur_filter():
|
||||||
|
with pytest.raises(ValueError):
|
||||||
|
ImageFilter.BoxBlur(-2)
|
||||||
|
|
|
@ -183,6 +183,9 @@ class BoxBlur(MultibandFilter):
|
||||||
name = "BoxBlur"
|
name = "BoxBlur"
|
||||||
|
|
||||||
def __init__(self, radius):
|
def __init__(self, radius):
|
||||||
|
if radius < 0:
|
||||||
|
msg = "radius must be >= 0"
|
||||||
|
raise ValueError(msg)
|
||||||
self.radius = radius
|
self.radius = radius
|
||||||
|
|
||||||
def filter(self, image):
|
def filter(self, image):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user