python pil create gif code example
Example 1: make gif from images in python
from PIL import Image
import glob
# Create the frames
frames = []
imgs = glob.glob("*.png")
for i in imgs:
new_frame = Image.open(i)
frames.append(new_frame)
# Save into a GIF file that loops forever
frames[0].save('png_to_gif.gif', format='GIF',
append_images=frames[1:],
save_all=True,
duration=300, loop=0)
Example 2: save gif python
first_im.save('out.gif', save_all=True, append_images=list_im, duration=100, loop=0)