mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-12 02:06:18 +03:00
Raise UnidentifiedImageError when opening TIFF without dimensions
This commit is contained in:
parent
7fe56d62c6
commit
3cdaee45f5
|
@ -93,6 +93,19 @@ class TestImageFile:
|
|||
assert p.image is not None
|
||||
assert (48, 48) == p.image.size
|
||||
|
||||
@pytest.mark.filterwarnings("ignore:Corrupt EXIF data")
|
||||
def test_incremental_tiff(self) -> None:
|
||||
with ImageFile.Parser() as p:
|
||||
with open("Tests/images/hopper.tif", "rb") as f:
|
||||
p.feed(f.read(1024))
|
||||
|
||||
# Check that insufficient data was given in the first feed
|
||||
assert not p.image
|
||||
|
||||
p.feed(f.read())
|
||||
assert p.image is not None
|
||||
assert (128, 128) == p.image.size
|
||||
|
||||
@skip_unless_feature("webp")
|
||||
def test_incremental_webp(self) -> None:
|
||||
with ImageFile.Parser() as p:
|
||||
|
|
|
@ -1433,8 +1433,12 @@ class TiffImageFile(ImageFile.ImageFile):
|
|||
logger.debug("- YCbCr subsampling: %s", self.tag_v2.get(YCBCRSUBSAMPLING))
|
||||
|
||||
# size
|
||||
xsize = self.tag_v2.get(IMAGEWIDTH)
|
||||
ysize = self.tag_v2.get(IMAGELENGTH)
|
||||
try:
|
||||
xsize = self.tag_v2[IMAGEWIDTH]
|
||||
ysize = self.tag_v2[IMAGELENGTH]
|
||||
except KeyError as e:
|
||||
msg = "Missing dimensions"
|
||||
raise TypeError(msg) from e
|
||||
if not isinstance(xsize, int) or not isinstance(ysize, int):
|
||||
msg = "Invalid dimensions"
|
||||
raise ValueError(msg)
|
||||
|
|
Loading…
Reference in New Issue
Block a user