import imageio
def create_gif(image_list, gif_name, duration = 0.3):
'''
:param image_list: 这个列表用于存放生成动图的图片
:param gif_name: 字符串,所生成gif文件名,带.gif后缀
:param duration: 图像间隔时间
:return:
'''
frames = []
for image_name in image_list:
frames.append(imageio.imread(image_name))
imageio.mimsave(gif_name, frames, 'GIF', duration=duration)
return
def main():
#这里放上自己所需要合成的图片(注意图片的路径)
image_list = ['0.png', '1.png', '2.png', '3.png','4.png', '5.png']
gif_name = 'new.gif'
duration = 0.6
create_gif(image_list, gif_name, duration)
if __name__ == '__main__':
main()