我建议不要使用visvis的images2gif,因为它与PIL/枕头有问题,并且没有得到积极的维护(我应该知道,因为我是作者)。
相反,请使用
imageio
快速肮脏的解决方案:
import imageio
images = []
for filename in filenames:
images.append(imageio.imread(filename))
imageio.mimsave('/path/to/movie.gif', images)
对于较长的电影,请使用流媒体方法:
import imageio
with imageio.get_writer('/path/to/movie.gif', mode='I') as writer:
for filename in filenames:
image = imageio.imread(filename)
writer.append_data(image)