mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-07-11 16:52:29 +03:00
Fixed type hints
This commit is contained in:
parent
36640de607
commit
7125fe4096
|
@ -45,7 +45,9 @@ class TestFileJpegXl:
|
|||
|
||||
def test_version(self) -> None:
|
||||
_jpegxl.JpegXlDecoderVersion()
|
||||
assert re.search(r"\d+\.\d+\.\d+$", features.version_module("jpegxl"))
|
||||
version = features.version_module("jpegxl")
|
||||
assert version is not None
|
||||
assert re.search(r"\d+\.\d+\.\d+$", version)
|
||||
|
||||
def test_read_rgb(self) -> None:
|
||||
"""
|
||||
|
|
|
@ -29,8 +29,7 @@ except ImportError:
|
|||
|
||||
|
||||
def test_read_exif_metadata() -> None:
|
||||
file_path = "Tests/images/flower.jxl"
|
||||
with Image.open(file_path) as image:
|
||||
with Image.open("Tests/images/flower.jxl") as image:
|
||||
assert image.format == "JPEG XL"
|
||||
exif_data = image.info.get("exif", None)
|
||||
assert exif_data
|
||||
|
@ -43,8 +42,8 @@ def test_read_exif_metadata() -> None:
|
|||
with Image.open("Tests/images/flower.jpg") as jpeg_image:
|
||||
expected_exif = jpeg_image.info["exif"]
|
||||
|
||||
# jpeg xl always returns exif without 'Exif\0\0' prefix
|
||||
assert exif_data == expected_exif[6:]
|
||||
# jpeg xl always returns exif without 'Exif\0\0' prefix
|
||||
assert exif_data == expected_exif[6:]
|
||||
|
||||
|
||||
def test_read_exif_metadata_without_prefix() -> None:
|
||||
|
@ -53,21 +52,20 @@ def test_read_exif_metadata_without_prefix() -> None:
|
|||
assert im.info["exif"][:6] != b"Exif\x00\x00"
|
||||
|
||||
exif = im.getexif()
|
||||
assert exif[305] == "Adobe Photoshop CS6 (Macintosh)"
|
||||
assert exif[305] == "Adobe Photoshop CS6 (Macintosh)"
|
||||
|
||||
|
||||
def test_read_icc_profile() -> None:
|
||||
file_path = "Tests/images/flower2.jxl"
|
||||
with Image.open(file_path) as image:
|
||||
with Image.open("Tests/images/flower2.jxl") as image:
|
||||
assert image.format == "JPEG XL"
|
||||
assert image.info.get("icc_profile", None)
|
||||
|
||||
icc = image.info["icc_profile"]
|
||||
|
||||
with Image.open("Tests/images/flower2.jxl") as jpeg_image:
|
||||
expected_icc = jpeg_image.info["icc_profile"]
|
||||
with Image.open("Tests/images/flower2.jxl") as jpeg_image:
|
||||
expected_icc = jpeg_image.info["icc_profile"]
|
||||
|
||||
assert icc == expected_icc
|
||||
assert icc == expected_icc
|
||||
|
||||
|
||||
def test_getxmp() -> None:
|
||||
|
@ -110,7 +108,7 @@ def test_4_byte_exif(monkeypatch: pytest.MonkeyPatch) -> None:
|
|||
def get_icc(self) -> None:
|
||||
pass
|
||||
|
||||
def get_exif(self) -> None:
|
||||
def get_exif(self) -> bytes:
|
||||
return b"\0\0\0\0"
|
||||
|
||||
def get_xmp(self) -> None:
|
||||
|
|
19
setup.py
19
setup.py
|
@ -753,7 +753,7 @@ class pil_build_ext(build_ext):
|
|||
self, "jxl/decode.h"
|
||||
):
|
||||
if _find_library_file(self, "jxl"):
|
||||
feature.set("jpegxl", "jxl jxl_threads")
|
||||
feature.set("jpegxl", "jxl")
|
||||
|
||||
if feature.want("imagequant"):
|
||||
_dbg("Looking for imagequant")
|
||||
|
@ -838,15 +838,6 @@ class pil_build_ext(build_ext):
|
|||
# alternate Windows name.
|
||||
feature.set("lcms", "lcms2_static")
|
||||
|
||||
if feature.get("jpegxl"):
|
||||
# jxl and jxl_threads are required
|
||||
libs = feature.get("jpegxl").split()
|
||||
defs = []
|
||||
|
||||
self._update_extension("PIL._jpegxl", libs, defs)
|
||||
else:
|
||||
self._remove_extension("PIL._jpegxl")
|
||||
|
||||
if feature.want("webp"):
|
||||
_dbg("Looking for webp")
|
||||
if all(
|
||||
|
@ -970,6 +961,14 @@ class pil_build_ext(build_ext):
|
|||
else:
|
||||
self._remove_extension("PIL._avif")
|
||||
|
||||
jpegxl = feature.get("jpegxl")
|
||||
if isinstance(jpegxl, str):
|
||||
# jxl and jxl_threads are required
|
||||
libs = [jpegxl, jpegxl + "_threads"]
|
||||
self._update_extension("PIL._jpegxl", libs)
|
||||
else:
|
||||
self._remove_extension("PIL._jpegxl")
|
||||
|
||||
tk_libs = ["psapi"] if sys.platform in ("win32", "cygwin") else []
|
||||
self._update_extension("PIL._imagingtk", tk_libs)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user