Merge pull request #6219 from radarhere/gif_eof

Do not update GIF frame position until local image is found
This commit is contained in:
Hugo van Kemenade 2022-05-27 08:29:38 +02:00 committed by GitHub
commit 0476914ee4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 11 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@ -354,16 +354,23 @@ def test_seek_rewind():
assert_image_equal(im, expected)
def test_n_frames():
for path, n_frames in [[TEST_GIF, 1], ["Tests/images/iss634.gif", 42]]:
# Test is_animated before n_frames
with Image.open(path) as im:
assert im.is_animated == (n_frames != 1)
@pytest.mark.parametrize(
"path, n_frames",
(
(TEST_GIF, 1),
("Tests/images/comment_after_last_frame.gif", 2),
("Tests/images/iss634.gif", 42),
),
)
def test_n_frames(path, n_frames):
# Test is_animated before n_frames
with Image.open(path) as im:
assert im.is_animated == (n_frames != 1)
# Test is_animated after n_frames
with Image.open(path) as im:
assert im.n_frames == n_frames
assert im.is_animated == (n_frames != 1)
# Test is_animated after n_frames
with Image.open(path) as im:
assert im.n_frames == n_frames
assert im.is_animated == (n_frames != 1)
def test_no_change():

View File

@ -185,8 +185,6 @@ class GifImageFile(ImageFile.ImageFile):
if not s or s == b";":
raise EOFError
self.__frame = frame
self.tile = []
palette = None
@ -291,6 +289,8 @@ class GifImageFile(ImageFile.ImageFile):
if interlace is None:
# self._fp = None
raise EOFError
self.__frame = frame
if not update_image:
return