Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

718
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda