Merge pull request #6269 from radarhere/jpeg2k

This commit is contained in:
Hugo van Kemenade 2022-05-04 15:52:32 +03:00 committed by GitHub
commit 3aef70ce39
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 2 deletions

Binary file not shown.

View File

@ -2,7 +2,15 @@ from io import BytesIO
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,
@ -377,3 +385,7 @@ class TestPyEncoder(CodecsTest):
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")

View File

@ -123,7 +123,7 @@ class ImageFile(Image.Image):
) 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