自制表情包——python合成gif
首先,你需要有imageio这个库。没有的话可以在环境中执行下列指令:
pip install imageio
下面是实现代码,简单易懂,这里就不多加赘述了:
import imageio
image_list = ['./piclogs/example/epoch' + str(x) + ".png" for x in range(5, 201, 5)]
gif_name = './piclogs/gifs/example.gif'
frames = []
for image_name in image_list:
frames.append(imageio.imread(image_name))
imageio.mimsave(gif_name, frames, 'GIF', duration=0.3)