mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-26 18:06:18 +03:00
Added per-frame disposal, tests
This commit is contained in:
parent
364a7b895e
commit
378f74672c
|
@ -392,6 +392,7 @@ def _write_single_frame(im, fp, palette):
|
||||||
def _write_multiple_frames(im, fp, palette):
|
def _write_multiple_frames(im, fp, palette):
|
||||||
|
|
||||||
duration = im.encoderinfo.get("duration", None)
|
duration = im.encoderinfo.get("duration", None)
|
||||||
|
disposal = im.encoderinfo.get('disposal', None)
|
||||||
|
|
||||||
im_frames = []
|
im_frames = []
|
||||||
frame_count = 0
|
frame_count = 0
|
||||||
|
@ -404,6 +405,8 @@ def _write_multiple_frames(im, fp, palette):
|
||||||
encoderinfo = im.encoderinfo.copy()
|
encoderinfo = im.encoderinfo.copy()
|
||||||
if isinstance(duration, (list, tuple)):
|
if isinstance(duration, (list, tuple)):
|
||||||
encoderinfo['duration'] = duration[frame_count]
|
encoderinfo['duration'] = duration[frame_count]
|
||||||
|
if isinstance(disposal, (list, tuple)):
|
||||||
|
encoderinfo["disposal"] = disposal[frame_count]
|
||||||
frame_count += 1
|
frame_count += 1
|
||||||
|
|
||||||
if im_frames:
|
if im_frames:
|
||||||
|
|
|
@ -274,12 +274,24 @@ class TestFileGif(PillowTestCase):
|
||||||
disposal=method
|
disposal=method
|
||||||
)
|
)
|
||||||
img = Image.open(out)
|
img = Image.open(out)
|
||||||
try:
|
for _ in range(2):
|
||||||
while True:
|
img.seek(img.tell() + 1)
|
||||||
img.seek(img.tell() + 1)
|
self.assertEqual(img.disposal_method, method)
|
||||||
self.assertEqual(img.disposal_method, method)
|
|
||||||
except EOFError:
|
|
||||||
pass
|
# check per frame disposal
|
||||||
|
im_list[0].save(
|
||||||
|
out,
|
||||||
|
save_all=True,
|
||||||
|
append_images=im_list[1:],
|
||||||
|
disposal=range(len(im_list))
|
||||||
|
)
|
||||||
|
|
||||||
|
img = Image.open(out)
|
||||||
|
|
||||||
|
for i in range(2):
|
||||||
|
img.seek(img.tell() + 1)
|
||||||
|
self.assertEqual(img.disposal_method, i+1)
|
||||||
|
|
||||||
def test_iss634(self):
|
def test_iss634(self):
|
||||||
img = Image.open("Tests/images/iss634.gif")
|
img = Image.open("Tests/images/iss634.gif")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user