1 # -*- coding: utf-8 -*- 2 """ 3 Created on Tue Apr 14 04:08:43 2020 4 5 @author: 49594 6 """ 7 8 import PIL.Image as Image 9 def get_gif(pics_dir,n,t=300): 10 imgs = [] 11 for i in range(n): 12 pic_name = '{}/{}.jpg'.format(pics_dir,i) 13 temp = Image.open(pic_name) 14 imgs.append(temp) 15 save_name = '{}.gif'.format(pics_dir) 16 imgs[0].save(save_name, save_all=True, append_images=imgs, duration=t) 17 return save_name 18 if __name__ == '__main__': 19 pics_dir = 'D:\python\img\kf' 20 save_name = get_gif(pics_dir,7,300) 21 print('制作完成。所属文件:{}'.format(save_name))