mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-10 19:56:47 +03:00
Bring back removed features, add deprecations and Release notes
This commit is contained in:
parent
a3468996c0
commit
56ca359c65
|
@ -27,6 +27,9 @@ def test_wheel_codecs() -> None:
|
||||||
|
|
||||||
def test_wheel_features() -> None:
|
def test_wheel_features() -> None:
|
||||||
expected_features = {
|
expected_features = {
|
||||||
|
"webp_anim",
|
||||||
|
"webp_mux",
|
||||||
|
"transp_webp",
|
||||||
"raqm",
|
"raqm",
|
||||||
"fribidi",
|
"fribidi",
|
||||||
"harfbuzz",
|
"harfbuzz",
|
||||||
|
|
|
@ -46,6 +46,18 @@ def test_version() -> None:
|
||||||
test(feature, features.version_feature)
|
test(feature, features.version_feature)
|
||||||
|
|
||||||
|
|
||||||
|
def test_webp_transparency() -> None:
|
||||||
|
assert features.check("transp_webp") == features.check_module("webp")
|
||||||
|
|
||||||
|
|
||||||
|
def test_webp_mux() -> None:
|
||||||
|
assert features.check("webp_mux") == features.check_module("webp")
|
||||||
|
|
||||||
|
|
||||||
|
def test_webp_anim() -> None:
|
||||||
|
assert features.check("webp_anim") == features.check_module("webp")
|
||||||
|
|
||||||
|
|
||||||
@skip_unless_feature("libjpeg_turbo")
|
@skip_unless_feature("libjpeg_turbo")
|
||||||
def test_libjpeg_turbo_version() -> None:
|
def test_libjpeg_turbo_version() -> None:
|
||||||
version = features.version("libjpeg_turbo")
|
version = features.version("libjpeg_turbo")
|
||||||
|
|
|
@ -57,6 +57,9 @@ Support for the following features can be checked:
|
||||||
* ``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.
|
* ``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.
|
||||||
* ``libimagequant``: (compile time) ImageQuant quantization support in :py:func:`PIL.Image.Image.quantize`. Run-time version number is available.
|
* ``libimagequant``: (compile time) ImageQuant quantization support in :py:func:`PIL.Image.Image.quantize`. Run-time version number is available.
|
||||||
* ``xcb``: (compile time) Support for X11 in :py:func:`PIL.ImageGrab.grab` via the XCB library.
|
* ``xcb``: (compile time) Support for X11 in :py:func:`PIL.ImageGrab.grab` via the XCB library.
|
||||||
|
* ``transp_webp``: Deprecated. Always ``True`` if WebP module is installed.
|
||||||
|
* ``webp_mux``: Deprecated. Always ``True`` if WebP module is installed.
|
||||||
|
* ``webp_anim``: Deprecated. Always ``True`` if WebP module is installed.
|
||||||
|
|
||||||
.. autofunction:: PIL.features.check_feature
|
.. autofunction:: PIL.features.check_feature
|
||||||
.. autofunction:: PIL.features.version_feature
|
.. autofunction:: PIL.features.version_feature
|
||||||
|
|
|
@ -58,6 +58,14 @@ JpegImageFile.huffman_ac and JpegImageFile.huffman_dc
|
||||||
The ``huffman_ac`` and ``huffman_dc`` dictionaries on JPEG images were unused. They
|
The ``huffman_ac`` and ``huffman_dc`` dictionaries on JPEG images were unused. They
|
||||||
have been deprecated, and will be removed in Pillow 12 (2025-10-15).
|
have been deprecated, and will be removed in Pillow 12 (2025-10-15).
|
||||||
|
|
||||||
|
Specific WebP Feature Checks
|
||||||
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
The following features ``features.check("transp_webp")``,
|
||||||
|
``features.check("webp_mux")``, and ``features.check("webp_anim")`` are now
|
||||||
|
always ``True`` if the WebP module is installed and should not be used.
|
||||||
|
These checks will be removed in Pillow 12.0.0 (2025-10-15).
|
||||||
|
|
||||||
API Changes
|
API Changes
|
||||||
===========
|
===========
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ import warnings
|
||||||
from typing import IO
|
from typing import IO
|
||||||
|
|
||||||
import PIL
|
import PIL
|
||||||
|
from PIL import _deprecate
|
||||||
|
|
||||||
from . import Image
|
from . import Image
|
||||||
|
|
||||||
|
@ -119,6 +120,9 @@ def get_supported_codecs() -> list[str]:
|
||||||
|
|
||||||
|
|
||||||
features = {
|
features = {
|
||||||
|
"webp_anim": ("PIL._webp", True, None),
|
||||||
|
"webp_mux": ("PIL._webp", True, None),
|
||||||
|
"transp_webp": ("PIL._webp", True, None),
|
||||||
"raqm": ("PIL._imagingft", "HAVE_RAQM", "raqm_version"),
|
"raqm": ("PIL._imagingft", "HAVE_RAQM", "raqm_version"),
|
||||||
"fribidi": ("PIL._imagingft", "HAVE_FRIBIDI", "fribidi_version"),
|
"fribidi": ("PIL._imagingft", "HAVE_FRIBIDI", "fribidi_version"),
|
||||||
"harfbuzz": ("PIL._imagingft", "HAVE_HARFBUZZ", "harfbuzz_version"),
|
"harfbuzz": ("PIL._imagingft", "HAVE_HARFBUZZ", "harfbuzz_version"),
|
||||||
|
@ -144,7 +148,11 @@ def check_feature(feature: str) -> bool | None:
|
||||||
|
|
||||||
try:
|
try:
|
||||||
imported_module = __import__(module, fromlist=["PIL"])
|
imported_module = __import__(module, fromlist=["PIL"])
|
||||||
return getattr(imported_module, flag)
|
if isinstance(flag, str):
|
||||||
|
return getattr(imported_module, flag)
|
||||||
|
else:
|
||||||
|
_deprecate.deprecate(f'check_feature("{feature}")', 12)
|
||||||
|
return flag
|
||||||
except ModuleNotFoundError:
|
except ModuleNotFoundError:
|
||||||
return None
|
return None
|
||||||
except ImportError as ex:
|
except ImportError as ex:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user