mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-25 00:34:14 +03:00
Only read the number of loops from the first frame
This commit is contained in:
parent
5cf02f816f
commit
2457eafabd
BIN
Tests/images/duplicate_number_of_loops.gif
Normal file
BIN
Tests/images/duplicate_number_of_loops.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.6 KiB |
|
@ -772,9 +772,16 @@ def test_number_of_loops(tmp_path):
|
|||
im = Image.new("L", (100, 100), "#000")
|
||||
im.save(out, loop=number_of_loops)
|
||||
with Image.open(out) as reread:
|
||||
|
||||
assert reread.info["loop"] == number_of_loops
|
||||
|
||||
# Check that even if a subsequent GIF frame has the number of loops specified,
|
||||
# only the value from the first frame is used
|
||||
with Image.open("Tests/images/duplicate_number_of_loops.gif") as im:
|
||||
assert im.info["loop"] == 2
|
||||
|
||||
im.seek(1)
|
||||
assert im.info["loop"] == 2
|
||||
|
||||
|
||||
def test_background(tmp_path):
|
||||
out = str(tmp_path / "temp.gif")
|
||||
|
|
|
@ -244,7 +244,7 @@ class GifImageFile(ImageFile.ImageFile):
|
|||
info["comment"] = comment
|
||||
s = None
|
||||
continue
|
||||
elif s[0] == 255:
|
||||
elif s[0] == 255 and frame == 0:
|
||||
#
|
||||
# application extension
|
||||
#
|
||||
|
@ -252,7 +252,7 @@ class GifImageFile(ImageFile.ImageFile):
|
|||
if block[:11] == b"NETSCAPE2.0":
|
||||
block = self.data()
|
||||
if len(block) >= 3 and block[0] == 1:
|
||||
info["loop"] = i16(block, 1)
|
||||
self.info["loop"] = i16(block, 1)
|
||||
while self.data():
|
||||
pass
|
||||
|
||||
|
@ -399,7 +399,7 @@ class GifImageFile(ImageFile.ImageFile):
|
|||
|
||||
if info.get("comment"):
|
||||
self.info["comment"] = info["comment"]
|
||||
for k in ["duration", "extension", "loop"]:
|
||||
for k in ["duration", "extension"]:
|
||||
if k in info:
|
||||
self.info[k] = info[k]
|
||||
elif k in self.info:
|
||||
|
|
Loading…
Reference in New Issue
Block a user