I'm trying to write a series of numpy array as an animated gif. I need to control strictly the colormap or palette (which color is associated with each integer value in the array), so that it matches the indices in the arrays
I found the imageio.mimwrite
. It has the ability to set the frame rate, and use compression, which seem great.
imageio.mimwrite('test.gif', ims, duration=0.2, subrectangles=True)
but I haven't found a way of setting a custom palette, only the number of colors seem to be settable... I know I can write image to disk and then imageio, but I would prefer not having to.
Using pillow, I can save the gif with custom palette:
im = Image.fromarray(...)
im.putpalette(...)
for i in im_list: i.putpalette(...)
im.save(filename, save_all=True, append_images=[image_list])
But I haven't found a way of setting both palette and framerate...
Any idea ?
Thanks!