python将图片序列保存成gif

这里用到的模块是imageio。用imageio.mimsave即可将图片序列保存成gif动态图。以下是本人编写的小实验:

import cv2
import imageio

paths = ["./images/0001.png", "./images/0002.png", "./images/0003.png", ...]
frames = []
for ima in paths:
    img = cv2.imread(ima)
    frames.append(img)
imageio.mimsave("demo.gif", frames, 'GIF', duration=0.1)

实现效果:
python将图片序列保存成gif_第1张图片

你可能感兴趣的:(python,python,opencv,gif)