Skip to content

Commit

Permalink
Merge pull request #6269 from radarhere/jpeg2k
Browse files Browse the repository at this point in the history
  • Loading branch information
hugovk committed May 4, 2022
2 parents 9d988da + 886fcbe commit 3aef70c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
Binary file added Tests/images/zero_height.j2k
Binary file not shown.
14 changes: 13 additions & 1 deletion Tests/test_imagefile.py
Expand Up @@ -2,7 +2,15 @@

import pytest

from PIL import BmpImagePlugin, EpsImagePlugin, Image, ImageFile, _binary, features
from PIL import (
BmpImagePlugin,
EpsImagePlugin,
Image,
ImageFile,
UnidentifiedImageError,
_binary,
features,
)

from .helper import (
assert_image,
Expand Down Expand Up @@ -377,3 +385,7 @@ def test_encode(self):

with pytest.raises(NotImplementedError):
encoder.encode_to_file(None, None)

def test_zero_height(self):
with pytest.raises(UnidentifiedImageError):
Image.open("Tests/images/zero_height.j2k")
2 changes: 1 addition & 1 deletion src/PIL/ImageFile.py
Expand Up @@ -123,7 +123,7 @@ def __init__(self, fp=None, filename=None):
) as v:
raise SyntaxError(v) from v

if not self.mode or self.size[0] <= 0:
if not self.mode or self.size[0] <= 0 or self.size[1] <= 0:
raise SyntaxError("not identified by this driver")
except BaseException:
# close the file only if we have opened it this constructor
Expand Down

0 comments on commit 3aef70c

Please sign in to comment.