mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-06-04 13:13:13 +03:00
Use skip_unless_feature_version
This commit is contained in:
parent
79e67cb5c3
commit
18ad4c867f
|
@ -12,6 +12,7 @@ from .helper import (
|
||||||
assert_image_similar,
|
assert_image_similar,
|
||||||
assert_image_similar_tofile,
|
assert_image_similar_tofile,
|
||||||
skip_unless_feature,
|
skip_unless_feature,
|
||||||
|
skip_unless_feature_version,
|
||||||
)
|
)
|
||||||
|
|
||||||
EXTRA_DIR = "Tests/images/jpeg2000"
|
EXTRA_DIR = "Tests/images/jpeg2000"
|
||||||
|
@ -384,34 +385,31 @@ def test_custom_comment():
|
||||||
assert bytes(unique_comment, "utf-8") in data
|
assert bytes(unique_comment, "utf-8") in data
|
||||||
|
|
||||||
|
|
||||||
|
@skip_unless_feature_version("jpg_2000", "2.4.0")
|
||||||
def test_plt_marker():
|
def test_plt_marker():
|
||||||
# Search the start of the codesteam for the PLT box (id 0xFF58)
|
# Search the start of the codesteam for the PLT box (id 0xFF58)
|
||||||
opj_version = re.search(r"(\d+\.\d+)\.\d+$", features.version_codec("jpg_2000"))
|
out = BytesIO()
|
||||||
assert opj_version is not None
|
test_card.save(out, "JPEG2000", no_jp2=True, add_plt=True)
|
||||||
|
out.seek(0)
|
||||||
|
while True:
|
||||||
|
box_bytes = out.read(2)
|
||||||
|
if len(box_bytes) == 0:
|
||||||
|
# End of steam encountered and no PLT or SOD
|
||||||
|
break
|
||||||
|
jp2_boxid = struct.unpack(">H", box_bytes)[0]
|
||||||
|
|
||||||
if float(opj_version[1]) >= 2.4:
|
if jp2_boxid == 0xFF4F:
|
||||||
out = BytesIO()
|
# No length specifier for main header
|
||||||
test_card.save(out, "JPEG2000", no_jp2=True, add_plt=True)
|
continue
|
||||||
out.seek(0)
|
elif jp2_boxid == 0xFF58:
|
||||||
while True:
|
# This is the PLT box we're looking for
|
||||||
box_bytes = out.read(2)
|
return
|
||||||
if len(box_bytes) == 0:
|
elif jp2_boxid == 0xFF93:
|
||||||
# End of steam encountered and no PLT or SOD
|
break
|
||||||
break
|
# SOD box encountered and no PLT, so it wasn't found
|
||||||
jp2_boxid = struct.unpack(">H", box_bytes)[0]
|
|
||||||
|
|
||||||
if jp2_boxid == 0xFF4F:
|
jp2_boxlength = struct.unpack(">H", out.read(2))[0]
|
||||||
# No length specifier for main header
|
out.seek(jp2_boxlength - 2, os.SEEK_CUR)
|
||||||
continue
|
|
||||||
elif jp2_boxid == 0xFF58:
|
|
||||||
# This is the PLT box we're looking for
|
|
||||||
return
|
|
||||||
elif jp2_boxid == 0xFF93:
|
|
||||||
break
|
|
||||||
# SOD box encountered and no PLT, so it wasn't found
|
|
||||||
|
|
||||||
jp2_boxlength = struct.unpack(">H", out.read(2))[0]
|
# The PLT box wasn't found
|
||||||
out.seek(jp2_boxlength - 2, os.SEEK_CUR)
|
raise ValueError
|
||||||
|
|
||||||
# The PLT box wasn't found
|
|
||||||
raise ValueError
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user