标签:bubuko dir filename 2.7 The alt main pen lis
#!/bin/python3 import matplotlib.pyplot as plt import imageio,os TIME_GAP=0.075 #两帧之间的时间间隔,秒为单位 FILE_PATH="./testwalk/" BEGIN_INDEX=1 END_INDEX=7 FORMAT=".jpg" # 返回gif def create_gif(image_list, gif_name): print(image_list) frames = [] for image_name in image_list: frames.append(imageio.imread(image_name)) # Save them as frames into a gif imageio.mimsave(gif_name, frames, ‘GIF‘, duration = TIME_GAP) return # 返回图片路径名的list def filenames_gen(): filenames = [] filenames.append(FILE_PATH+"-2.77555756156e-17.jpg") # filenames=(fn for fn in os.listdir(‘./testwalk‘) if fn.endswith(FORMAT)) # filenames=[fn for fn in os.listdir(‘./testwalk‘) if fn.endswith(FORMAT)] for i in range(BEGIN_INDEX,END_INDEX+1): filenames.append(FILE_PATH+str(i/10)+FORMAT) filenames.append(FILE_PATH+str(-i/10)+FORMAT) filenames.reverse() print(filenames) return filenames if __name__ == ‘__main__‘: create_gif(filenames_gen(),‘created_gif.gif‘ )
标签:bubuko dir filename 2.7 The alt main pen lis
原文地址:https://www.cnblogs.com/zealousness/p/9346339.html