mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-27 09:44:31 +03:00
Merge pull request #7329 from radarhere/gif
Allow "loop=None" when saving GIF images
This commit is contained in:
commit
6651a31436
|
@ -875,6 +875,14 @@ def test_identical_frames_to_single_frame(duration, tmp_path):
|
||||||
assert reread.info["duration"] == 8500
|
assert reread.info["duration"] == 8500
|
||||||
|
|
||||||
|
|
||||||
|
def test_loop_none(tmp_path):
|
||||||
|
out = str(tmp_path / "temp.gif")
|
||||||
|
im = Image.new("L", (100, 100), "#000")
|
||||||
|
im.save(out, loop=None)
|
||||||
|
with Image.open(out) as reread:
|
||||||
|
assert "loop" not in reread.info
|
||||||
|
|
||||||
|
|
||||||
def test_number_of_loops(tmp_path):
|
def test_number_of_loops(tmp_path):
|
||||||
number_of_loops = 2
|
number_of_loops = 2
|
||||||
|
|
||||||
|
|
|
@ -253,7 +253,7 @@ their :py:attr:`~PIL.Image.Image.info` values.
|
||||||
|
|
||||||
**loop**
|
**loop**
|
||||||
Integer number of times the GIF should loop. 0 means that it will loop
|
Integer number of times the GIF should loop. 0 means that it will loop
|
||||||
forever. By default, the image will not loop.
|
forever. If omitted or ``None``, the image will not loop.
|
||||||
|
|
||||||
**comment**
|
**comment**
|
||||||
A comment about the image.
|
A comment about the image.
|
||||||
|
|
|
@ -912,7 +912,7 @@ def _get_global_header(im, info):
|
||||||
info
|
info
|
||||||
and (
|
and (
|
||||||
"transparency" in info
|
"transparency" in info
|
||||||
or "loop" in info
|
or info.get("loop") is not None
|
||||||
or info.get("duration")
|
or info.get("duration")
|
||||||
or info.get("comment")
|
or info.get("comment")
|
||||||
)
|
)
|
||||||
|
@ -937,7 +937,7 @@ def _get_global_header(im, info):
|
||||||
# Global Color Table
|
# Global Color Table
|
||||||
_get_header_palette(palette_bytes),
|
_get_header_palette(palette_bytes),
|
||||||
]
|
]
|
||||||
if "loop" in info:
|
if info.get("loop") is not None:
|
||||||
header.append(
|
header.append(
|
||||||
b"!"
|
b"!"
|
||||||
+ o8(255) # extension intro
|
+ o8(255) # extension intro
|
||||||
|
|
Loading…
Reference in New Issue
Block a user