Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added Tests/images/frame_size.mpo
Binary file not shown.
Binary file removed Tests/images/sugarshack_frame_size.mpo
Binary file not shown.
12 changes: 6 additions & 6 deletions Tests/test_file_mpo.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,16 @@ def test_exif(test_file: str) -> None:


def test_frame_size() -> None:
# This image has been hexedited to contain a different size
# in the SOF marker of the second frame
with Image.open("Tests/images/sugarshack_frame_size.mpo") as im:
assert im.size == (640, 480)
with Image.open("Tests/images/frame_size.mpo") as im:
assert im.size == (56, 70)
im.load()

im.seek(1)
assert im.size == (680, 480)
assert im.size == (349, 434)
im.load()

im.seek(0)
assert im.size == (640, 480)
assert im.size == (56, 70)


def test_ignore_frame_size() -> None:
Expand Down
2 changes: 2 additions & 0 deletions src/PIL/JpegImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,8 @@ def SOF(self: JpegImageFile, marker: int) -> None:
n = i16(self.fp.read(2)) - 2
s = ImageFile._safe_read(self.fp, n)
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]
if self.bits != 8:
Expand Down
Loading