mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-26 01:04:29 +03:00
Added tuple option for durations
This commit is contained in:
parent
87092ad4f8
commit
e530f2a228
|
@ -361,7 +361,7 @@ def _save(im, fp, filename, save_all=False):
|
|||
for im_frame in ImageSequence.Iterator(imSequence):
|
||||
encoderinfo = im.encoderinfo.copy()
|
||||
im_frame = _convert_mode(im_frame)
|
||||
if isinstance(duration, list):
|
||||
if isinstance(duration, (list, tuple)):
|
||||
encoderinfo["duration"] = duration[frame_count]
|
||||
frame_count += 1
|
||||
|
||||
|
|
|
@ -290,6 +290,8 @@ class TestFileGif(PillowTestCase):
|
|||
Image.new('L', (100, 100), '#111'),
|
||||
Image.new('L', (100, 100), '#222'),
|
||||
]
|
||||
|
||||
#duration as list
|
||||
im_list[0].save(
|
||||
out,
|
||||
save_all=True,
|
||||
|
@ -305,6 +307,24 @@ class TestFileGif(PillowTestCase):
|
|||
except EOFError:
|
||||
pass
|
||||
|
||||
# duration as tuple
|
||||
im_list[0].save(
|
||||
out,
|
||||
save_all=True,
|
||||
append_images=im_list[1:],
|
||||
duration=tuple(duration_list)
|
||||
)
|
||||
reread = Image.open(out)
|
||||
|
||||
for duration in duration_list:
|
||||
self.assertEqual(reread.info['duration'], duration)
|
||||
try:
|
||||
reread.seek(reread.tell() + 1)
|
||||
except EOFError:
|
||||
pass
|
||||
|
||||
|
||||
|
||||
def test_number_of_loops(self):
|
||||
number_of_loops = 2
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user