Alright so I have some code that takes user input, fetches each letter's corresponding gif (a dancing letter) and stitches them together to form a word. Kind of like an animated font, basically.
My problem is that with PIL, it occasionally fills the background of one of the letters for around 1 frame with a red color, as demonstrated here:

This is my code that generates this
import sys
from PIL import Image
from PIL import GifImagePlugin
from io import BytesIO
def text(str, procid):
t = []
for c in str:
t.append('letters/' + c + '.gif')
images = [Image.open(x) for x in t]
widths, heights = zip(*(i.size for i in images))
total_width = sum(widths)
max_height = max(heights)
x_offset = 0
imgs = []
for frame in range(0, images[0].n_frames):
new = Image.new('RGBA', (total_width, max_height))
x_offset = 0
for im in images:
im.seek(frame)
new.paste(im, (x_offset,0))
x_offset += im.size[0]
imgs.append(new)
img_io = BytesIO()
new.save(img_io, 'GIF', transparency=0, save_all=True, append_images=imgs, loop=0, disposal=2,duration=1,optimize=True)
img_io.seek(0)
return img_io
Any ideas as to why it does this, and is it possible to fix this?
Edit: I've attached the input GIFS used to create the animated "TEST"
e.gif https://i.stack.imgur.com/PQfMK.gif
s.gif https://i.stack.imgur.com/7PQp5.gif
t.gif https://i.stack.imgur.com/DMLrg.gif
Edit 2: All the letters have the same amount of frames, and the red background is not present anywhere in S.gif meaning it has to be a PIL problem or a problem with my code.

