Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

719
Visualizações
Why does this red color fill only one frame PIL?

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:

demo

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.

over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

I was able to fix it by downloading a different set of the same dancing letters from a somewhat more reputable source. (The previous ones were uploaded to tenor so it could've been modified in some ways)

over 4 years ago · Santiago Trujillo Relatório

0

to me there is more going on,

check one of the s.gif frames :

enter image description here

and nevertheless my output gif using your code looks like:

enter image description here

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda