1、把图片按顺序命名,
2、代码逻辑比较简单,只是现成的模块使用,代码如下
# -*- coding: UTF-8 -*-
import imageio
def create_gif(image_list, gif_name):
frames = []
for image_name in image_list:
frames.append(imageio.imread(image_name))
imageio.mimsave(gif_name, frames, 'GIF', duration=1)
return
def main():
image_list = ["d:\\gif\\"+str(x)+".png" for x in range(1,30) ]
gif_name = 'd:\\created_gif.gif'
create_gif(image_list, gif_name)
if __name__ == "__main__":
main()
3、效果: