guopengfa
发布于 2022-04-21 / 2520 阅读 / 0 评论 / 0 点赞

generate gif file from static image

import imageio, os, sys

def png_gif(path):
    png_lst = os.listdir(path)
    frames = []
    for i in png_lst:
        frames.append(imageio.imread(path + i))
    # for i in range(0, 51):
    #     i = i*4 + 1
    #     k = str(i)
    #     z = k.zfill(4)
        # frames.append(imageio.imread(path + "/pten" + z + ".png"))
    imageio.mimsave("result.gif", frames, 'GIF', duration=0.5)

def main():
    path = str(sys.argv[1])
    png_gif(path)
    
if __name__=="__main__":
    main()  

评论