目录
PIL库制作动图
def img(): # 通过PIL库制作动图
from PIL import Image
images = []
for i in range(11):
im = Image.open('../IMG/{}.jpg'.format(i + 1))
images.append(im)
images[0].save("test.gif", save_all=True, loop=True, append_images=images[1:], duration=500)
imageio库制作动图及视频
def gif(): # imageio库制作及视频
import imageio
frames = []
images_path = []
duration = 0.5 # duration图片之间的间隔
for i in range(11):
images_path.append('../IMG/{}.jpg'.format(i + 1))
for imagename in images_path:
frames.append(imageio.imread_v2(imagename))
# imageio.mimsave('test001.gif', frames, 'GIF'