Skip to content

Commit 709f103

Browse files
committed
Bring back removed features, add deprecations and Release notes
1 parent 8303152 commit 709f103

File tree

4 files changed

+30
-4
lines changed

4 files changed

+30
-4
lines changed

Tests/test_features.py

+12
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,18 @@ def test(name: str, function: Callable[[str], str | None]) -> None:
4646
test(feature, features.version_feature)
4747

4848

49+
def test_webp_transparency() -> None:
50+
assert features.check("transp_webp") == features.check_module("webp")
51+
52+
53+
def test_webp_mux() -> None:
54+
assert features.check("webp_mux") == features.check_module("webp")
55+
56+
57+
def test_webp_anim() -> None:
58+
assert features.check("webp_anim") == features.check_module("webp")
59+
60+
4961
@skip_unless_feature("libjpeg_turbo")
5062
def test_libjpeg_turbo_version() -> None:
5163
version = features.version("libjpeg_turbo")

docs/reference/features.rst

+3
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ Support for the following features can be checked:
5757
* ``raqm``: Raqm library, required for ``ImageFont.Layout.RAQM`` in :py:func:`PIL.ImageFont.truetype`. Run-time version number is available for Raqm 0.7.0 or newer.
5858
* ``libimagequant``: (compile time) ImageQuant quantization support in :py:func:`PIL.Image.Image.quantize`. Run-time version number is available.
5959
* ``xcb``: (compile time) Support for X11 in :py:func:`PIL.ImageGrab.grab` via the XCB library.
60+
* ``transp_webp``: Deprecated. Always ``True`` if WebP module is installed.
61+
* ``webp_mux``: Deprecated. Always ``True`` if WebP module is installed.
62+
* ``webp_anim``: Deprecated. Always ``True`` if WebP module is installed.
6063

6164
.. autofunction:: PIL.features.check_feature
6265
.. autofunction:: PIL.features.version_feature

docs/releasenotes/11.0.0.rst

+6-3
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,13 @@ similarly removed.
4343
Deprecations
4444
============
4545

46-
TODO
47-
^^^^
46+
WebP Features Test
47+
^^^^^^^^^^^^^^^^^^
4848

49-
TODO
49+
The following features ``features.check("transp_webp")``,
50+
``features.check("webp_mux")``, and ``features.check("webp_anim")`` are now
51+
always ``True`` if the WebP module is installed and sohuld not be used.
52+
These checks wil be removed in Pillow 12.0.0 (2025-10-15).
5053

5154
API Changes
5255
===========

src/PIL/features.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from typing import IO
88

99
import PIL
10+
from PIL import _deprecate
1011

1112
from . import Image
1213

@@ -119,6 +120,9 @@ def get_supported_codecs() -> list[str]:
119120

120121

121122
features = {
123+
"webp_anim": ("PIL._webp", True, None),
124+
"webp_mux": ("PIL._webp", True, None),
125+
"transp_webp": ("PIL._webp", True, None),
122126
"raqm": ("PIL._imagingft", "HAVE_RAQM", "raqm_version"),
123127
"fribidi": ("PIL._imagingft", "HAVE_FRIBIDI", "fribidi_version"),
124128
"harfbuzz": ("PIL._imagingft", "HAVE_HARFBUZZ", "harfbuzz_version"),
@@ -144,7 +148,11 @@ def check_feature(feature: str) -> bool | None:
144148

145149
try:
146150
imported_module = __import__(module, fromlist=["PIL"])
147-
return getattr(imported_module, flag)
151+
if isinstance(flag, str):
152+
return getattr(imported_module, flag)
153+
else:
154+
_deprecate.deprecate(f'check_feature("{feature}")', 12)
155+
return flag
148156
except ModuleNotFoundError:
149157
return None
150158
except ImportError as ex:

0 commit comments

Comments
 (0)