为什么这种红色只填充一帧 PIL?

Why does this red color fill only one frame PIL?

好吧,我有一些代码可以接受用户输入,获取每个字母对应的 gif(一个跳舞的字母)并将它们拼接在一起形成一个单词。基本上有点像动画字体。

我的问题是,使用 PIL,它偶尔会用红色填充其中一个字母的背景约 1 帧,如下所示:

这是我生成的代码

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

关于它为什么这样做的任何想法,是否有可能解决这个问题?

编辑:我附上了用于创建动画“TEST”的输入 GIFS

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

编辑 2:所有字母的帧数都相同,红色背景在 S.gif 中没有出现,这意味着它必须是 PIL 问题或我的代码有问题。

对我来说还有更多事情要做,

检查 s.gif 帧之一:

尽管如此,我使用您的代码输出的 gif 看起来像:

我可以通过从更有信誉的来源下载一组不同的相同舞蹈字母来修复它。 (之前的上传到tenor所以可以在某些方面进行修改)