python output gif code example
Example 1: make gif from images in python
import glob
import os
gif_name = 'outputName'
file_list = glob.glob('*.png')
list.sort(file_list, key=lambda x: int(x.split('_')[1].split('.png')[0]))
with open('image_list.txt', 'w') as file:
for item in file_list:
file.write("%s\n" % item)
os.system('convert @image_list.txt {}.gif'.format(gif_name))
Example 2: python create gif
from moviepy.editor import *
clip = (VideoFileClip("video.mp4")
.subclip((1,22.65),(1,23.2))
.resize(0.3))
clip.write_gif("video.gif")