pillow version:5.4.1
The problem is I can see all the frames in the gif.
Expectation: in the lifecycle of a gif having 5 frames each frames should be visible for a fraction of time and at the end of gif only 5th frame should be visible.
Actual: In my case at the end of the gif I can see all the frames 1-2-3-4-5.
There are 5 frames in the gif animation and all the frames are in gif format(static) I also tried with png files too but I am getting the same result.
All my frames are with transparent background.
from PIL import Image
frame_list = []
frame_list.append("object_1.gif")
frame_list.append("object_2.gif")
frame_list.append("object_3.gif")
frame_list.append("object_4.gif")
frame_list.append("object_5.gif")
images = []
for n in frame_list:
frame = Image.open(n)
images.append(frame)
images[0].save('anitest.gif',
save_all=True,
format='GIF',
append_images=images[1:],
duration=200,
loop=0)
If anyone encountered the same issue please let me know what am I doing wrong?
With the below code using imageio it's working but I am loosing transparency and its very slow compare PIL
images = []
for filename in names:
images.append(imageio.imread(filename))
imageio.mimsave('anitest.gif', images,duration=0.3)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…