python imageio 图片生成gif
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python imageio 图片生成gif相关的知识,希望对你有一定的参考价值。
#!/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\' )
以上是关于python imageio 图片生成gif的主要内容,如果未能解决你的问题,请参考以下文章