mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-03-06 05:05:48 +03:00
add tests for subsampled jpeg2000 image decoding
This commit is contained in:
parent
4f4c3b34f8
commit
2586b7ddef
|
@ -1,3 +1,4 @@
|
|||
import os
|
||||
import re
|
||||
from io import BytesIO
|
||||
|
||||
|
@ -12,6 +13,8 @@ from .helper import (
|
|||
skip_unless_feature,
|
||||
)
|
||||
|
||||
EXTRA_DIR = "Tests/images/jpeg2000"
|
||||
|
||||
pytestmark = skip_unless_feature("jpg_2000")
|
||||
|
||||
test_card = Image.open("Tests/images/test-card.png")
|
||||
|
@ -233,3 +236,23 @@ def test_parser_feed():
|
|||
|
||||
# Assert
|
||||
assert p.image.size == (640, 480)
|
||||
|
||||
|
||||
@pytest.mark.skipif(
|
||||
not os.path.exists(EXTRA_DIR), reason="Extra image files not installed"
|
||||
)
|
||||
@pytest.mark.parametrize("name", ("subsampling_1", "subsampling_2", "zoo1", "zoo2"))
|
||||
def test_subsampling_decode(name):
|
||||
test = f"{EXTRA_DIR}/{name}.jp2"
|
||||
reference = f"{EXTRA_DIR}/{name}.ppm"
|
||||
|
||||
with Image.open(test) as im:
|
||||
epsilon = 3 # for YCbCr images
|
||||
with Image.open(reference) as im2:
|
||||
width, height = im2.size
|
||||
if name[-1] == "2":
|
||||
# RGB reference images are downscaled
|
||||
epsilon = 3e-3
|
||||
width, height = width * 2, height * 2
|
||||
expected = im2.resize((width, height), Image.NEAREST)
|
||||
assert_image_similar(im, expected, epsilon)
|
||||
|
|
Loading…
Reference in New Issue
Block a user