Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
13 changes: 13 additions & 0 deletions Tests/test_box_blur.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ def test_color_modes() -> None:
box_blur(sample.convert("L"))
box_blur(sample.convert("LA"))
box_blur(sample.convert("LA").convert("La"))
box_blur(sample.convert("I;16"))
box_blur(sample.convert("I;16L"))
box_blur(sample.convert("I;16B"))
box_blur(sample.convert("I;16N"))
with pytest.raises(ValueError):
box_blur(sample.convert("I"))
with pytest.raises(ValueError):
Expand All @@ -73,6 +77,15 @@ def test_color_modes() -> None:
box_blur(sample.convert("YCbCr"))


@pytest.mark.parametrize("mode", ("I;16", "I;16L", "I;16B", "I;16N"))
def test_i16_max_value(mode: str) -> None:
im = Image.new(mode, sample.size, 65535)
assert (
box_blur(im, 600, 3).get_flattened_data()
== (65535,) * sample.width * sample.height
)


@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
Expand Down
29 changes: 29 additions & 0 deletions Tests/test_image_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,35 @@ def test_consistency_i16_high_byte(mode: str) -> None:
assert im.getpixel((4, 4)) == 1000


@pytest.mark.parametrize(
"filter_to_apply",
(
ImageFilter.GaussianBlur,
ImageFilter.GaussianBlur(0),
ImageFilter.GaussianBlur(5),
ImageFilter.GaussianBlur((2, 5)),
ImageFilter.BoxBlur(0),
ImageFilter.BoxBlur(5),
ImageFilter.BoxBlur((2, 5)),
),
)
@pytest.mark.parametrize("mode", ("I;16", "I;16L", "I;16B", "I;16N"))
def test_blur_i16(
filter_to_apply: ImageFilter.Filter | type[ImageFilter.Filter], mode: str
) -> None:
im = hopper("L")
reference = im.filter(filter_to_apply)
result = im.convert(mode).filter(filter_to_apply)
assert result.mode == mode
assert_image_equal(result.convert("L"), reference)


@pytest.mark.parametrize("mode", ("I;16", "I;16L", "I;16B", "I;16N"))
def test_unsharp_mask_i16(mode: str) -> None:
with pytest.raises(ValueError, match="image has wrong mode"):
hopper(mode).filter(ImageFilter.UnsharpMask)


@pytest.mark.parametrize("size", (-1, math.nan, math.inf, 2**31))
def test_invalid_box_blur_filter(size: int) -> None:
for radius in (size, (size, size), (size, 1), (1, size)):
Expand Down
56 changes: 56 additions & 0 deletions docs/releasenotes/13.1.0.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
13.1.0
------

Security
========

TODO
^^^^

TODO

:cve:`YYYY-XXXXX`: TODO
^^^^^^^^^^^^^^^^^^^^^^^

TODO

Backwards incompatible changes
==============================

TODO
^^^^

TODO

Deprecations
============

TODO
^^^^

TODO

API changes
===========

TODO
^^^^

TODO

API additions
=============

TODO
^^^^

TODO

Other changes
=============

Blurring I;16 images
^^^^^^^^^^^^^^^^^^^^

:py:class:`~PIL.ImageFilter.GaussianBlur` and :py:class:`~PIL.ImageFilter.BoxBlur`
now support I;16, I;16L, I;16B and I;16N images.
1 change: 1 addition & 0 deletions docs/releasenotes/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ expected to be backported to earlier versions.
:maxdepth: 2

versioning
13.1.0
13.0.0
12.3.0
12.2.0
Expand Down
Loading
Loading