mirror of
https://github.com/python-pillow/Pillow.git
synced 2026-02-05 14:59:32 +03:00
Raise warning if image file identification fails due to lack of support
This commit is contained in:
parent
e99989fde4
commit
099048b874
|
|
@ -23,8 +23,9 @@ class TestUnsupportedJpegXl:
|
|||
monkeypatch.setattr(JpegXlImagePlugin, "SUPPORTED", False)
|
||||
|
||||
with pytest.raises(OSError):
|
||||
with Image.open("Tests/images/hopper.jxl"):
|
||||
pass
|
||||
with pytest.warns(UserWarning, match="JXL support not installed"):
|
||||
with Image.open("Tests/images/hopper.jxl"):
|
||||
pass
|
||||
|
||||
|
||||
@skip_unless_feature("jpegxl")
|
||||
|
|
|
|||
|
|
@ -22,13 +22,12 @@ except ImportError:
|
|||
# OPEN_COUNTS_FRAMES = True
|
||||
|
||||
|
||||
def _accept(prefix: bytes) -> bool:
|
||||
def _accept(prefix: bytes) -> bool | str:
|
||||
is_jxl = prefix.startswith(
|
||||
(b"\xff\x0a", b"\x00\x00\x00\x0c\x4a\x58\x4c\x20\x0d\x0a\x87\x0a")
|
||||
)
|
||||
if is_jxl and not SUPPORTED:
|
||||
msg = "image file could not be identified because JXL support not installed"
|
||||
raise SyntaxError(msg)
|
||||
return "image file could not be identified because JXL support not installed"
|
||||
return is_jxl
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user