Skip to content

Commit

Permalink
Merge pull request #6250 from radarhere/jpeg2000
Browse files Browse the repository at this point in the history
  • Loading branch information
hugovk committed Apr 29, 2022
2 parents 489d6f3 + 9c9aa99 commit 7d5162c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
11 changes: 4 additions & 7 deletions Tests/test_file_icns.py
Expand Up @@ -4,15 +4,13 @@

import pytest

from PIL import IcnsImagePlugin, Image, _binary, features
from PIL import IcnsImagePlugin, Image, _binary

from .helper import assert_image_equal, assert_image_similar_tofile
from .helper import assert_image_equal, assert_image_similar_tofile, skip_unless_feature

# sample icon file
TEST_FILE = "Tests/images/pillow.icns"

ENABLE_JPEG2K = features.check_codec("jpg_2000")


def test_sanity():
# Loading this icon by default should result in the largest size
Expand Down Expand Up @@ -111,14 +109,12 @@ def test_older_icon():
assert im2.size == (wr, hr)


@skip_unless_feature("jpg_2000")
def test_jp2_icon():
# This icon uses JPEG 2000 images instead of the PNG images.
# The advantage of doing this is that OS X 10.5 supports JPEG 2000
# but not PNG; some commercial software therefore does just this.

if not ENABLE_JPEG2K:
return

with Image.open("Tests/images/pillow3.icns") as im:
for w, h, r in im.info["sizes"]:
wr = w * r
Expand Down Expand Up @@ -149,6 +145,7 @@ def test_not_an_icns_file():
IcnsImagePlugin.IcnsFile(fp)


@skip_unless_feature("jpg_2000")
def test_icns_decompression_bomb():
with Image.open(
"Tests/images/oom-8ed3316a4109213ca96fb8a256a0bfefdece1461.icns"
Expand Down
4 changes: 3 additions & 1 deletion Tests/test_image.py
Expand Up @@ -7,7 +7,7 @@

import pytest

from PIL import Image, ImageDraw, ImagePalette, UnidentifiedImageError
from PIL import Image, ImageDraw, ImagePalette, UnidentifiedImageError, features

from .helper import (
assert_image_equal,
Expand Down Expand Up @@ -161,6 +161,8 @@ def test_pathlib(self, tmp_path):
assert im.size == (128, 128)

for ext in (".jpg", ".jp2"):
if ext == ".jp2" and not features.check_codec("jpg_2000"):
pytest.skip("jpg_2000 not available")
temp_file = str(tmp_path / ("temp." + ext))
if os.path.exists(temp_file):
os.remove(temp_file)
Expand Down

0 comments on commit 7d5162c

Please sign in to comment.