Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

717
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!