Skip to content

Odd color change in GIF after overlaying text #4202

@Technerder

Description

@Technerder

What did you do?

Tried to overlay some text over a GIF file

What did you expect to happen?

I expected the outcome to look almost identical to the original in terms of quality.

What actually happened?

The final result quality text looks odd, and the GIF looks like it had it's color inverted

What are your OS, Python and Pillow versions?

  • OS: Windows
  • Python: 3.8
  • Pillow: 6.2.1

Code used to modify the GIF from a URL:

image = Image.open(BytesIO(await request.read()))
frames = []
for frame in ImageSequence.Iterator(image):
    frame_bytes = BytesIO()
    draw = ImageDraw.Draw(frame)
    draw_text(frame, draw, top_text, 'top')
    draw_text(frame, draw, bottom_text, 'bottom')
    frame.save(frame_bytes, format='GIF')
    frames.append(Image.open(frame_bytes))
    del draw
edited_image_bytes = BytesIO()
frames[0].save(edited_image_bytes, format='GIF', save_all=True, append_images=frames[1:])

draw_text and draw_text_with_outline methods: https://hastebin.com/xoxecosawu.py

Files: Gifs.zip

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions