This commit is contained in:
Andrew Murray 2025-09-23 02:18:20 +00:00 committed by GitHub
commit 06ce3758e2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 8 additions and 6 deletions

BIN
Tests/images/frame_size.mpo Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 117 KiB

View File

@ -104,16 +104,16 @@ def test_exif(test_file: str) -> None:
def test_frame_size() -> None: def test_frame_size() -> None:
# This image has been hexedited to contain a different size with Image.open("Tests/images/frame_size.mpo") as im:
# in the SOF marker of the second frame assert im.size == (56, 70)
with Image.open("Tests/images/sugarshack_frame_size.mpo") as im: im.load()
assert im.size == (640, 480)
im.seek(1) im.seek(1)
assert im.size == (680, 480) assert im.size == (349, 434)
im.load()
im.seek(0) im.seek(0)
assert im.size == (640, 480) assert im.size == (56, 70)
def test_ignore_frame_size() -> None: def test_ignore_frame_size() -> None:

View File

@ -193,6 +193,8 @@ def SOF(self: JpegImageFile, marker: int) -> None:
n = i16(self.fp.read(2)) - 2 n = i16(self.fp.read(2)) - 2
s = ImageFile._safe_read(self.fp, n) s = ImageFile._safe_read(self.fp, n)
self._size = i16(s, 3), i16(s, 1) self._size = i16(s, 3), i16(s, 1)
if self._im is not None and self.size != self.im.size:
self._im = None
self.bits = s[0] self.bits = s[0]
if self.bits != 8: if self.bits != 8: