The following code creates a GIF from two images:
# GIFs are always palette images so they would be converted later anyway
im1 = PIL.Image.open('grin-emoji-by-twitter-rgba.png').convert('P')
im2 = PIL.Image.open('grin-emoji-by-twitter-rgba-2.png').convert('P')
im1.save('output.gif', save_all=True, append_images=[im2, im1, im2], loop=0, duration=200, transparency=255)
However the result is unexpectedly wrong. The first frame is fine, but subsequent frames contain a black rectangle around the updating region instead of transparency:
In my opinion the error is as follows: On the first image we specify the index 255 to be the index for completely transparent color. However the save
function only seems to convert index 255 to transparency on the first frame, but skips this step on all other frames.
Is there any way to circumvent this?