1from PIL import Image
2import glob
3
4# Create the frames
5frames = []
6imgs = glob.glob("*.png")
7for i in imgs:
8 new_frame = Image.open(i)
9 frames.append(new_frame)
10
11# Save into a GIF file that loops forever
12frames[0].save('png_to_gif.gif', format='GIF',
13 append_images=frames[1:],
14 save_all=True,
15 duration=300, loop=0)
16
1from moviepy.editor import *
2
3clip = (VideoFileClip("video.mp4")
4 .subclip((1,22.65),(1,23.2))
5 .resize(0.3))
6clip.write_gif("video.gif")
7
1import imageio
2images = []
3for filename in filenames:
4 images.append(imageio.imread(filename))
5imageio.mimsave('/path/to/movie.gif', images)
6
1import imageio
2with imageio.get_writer('/path/to/movie.gif', mode='I') as writer:
3 for filename in filenames:
4 image = imageio.imread(filename)
5 writer.append_data(image)
6