question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Transparency does not work as expected in gif creation

See original GitHub issue

Thank you for this excessively fun implementation! While playing around with it, I noticed that transparency doesn’t seem to work quite right in GIF mode.

When glitching a reasonably complex image with a transparent background, the background appears to turn black: square2 glitched_square2

Interestingly, when glitching a single-color image with a transparent background, I get a black background again but the blue rectangle has become transparent: square glitched_square

As such, I suspect this results from not keeping a constant palette when operating over the individual frames. Note that this seems to occur during the final combination and saving of the frames, as the individual frame files written to the Glitched GIF directory all appear to be correct.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:1
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
ojensen5115commented, Feb 22, 2020

I suspect so. As best as I can tell, it looks like this stems from the different frames having different palettes which don’t line up (i.e. transparent in frame 0 might be the palette index of blue in frame 3). The second (single color) example above seems to corroborate the idea of palette indexes getting swapped around.

I spent an hour or so this morning reading through pillow docs and issues, and while there’s a lot around transparency behaving weird, I didn’t see anything that seems to match this issue entirely and most of the issues seemed like they had already been resolved.

I’m sorry I can’t be of more help, I’ll continue looking around and seeing what I can find.

0reactions
agentx3commented, Apr 26, 2022

Not sure if things are different now than before since I just started using this. But it appears that even when I save each individual layer it appears that each have also lost their transparency. I’ve tried some of the methods in the above comment to no avail. What I do notice it seems that this happens in particular only to larger resolution files.

EDIT: Nevermind??? I think I’m trippin’ balls here. I’m running the solution from https://gist.github.com/egocarib/ea022799cca8a102d14c54a22c45efe0 and it works just fine??? It’s suddenly working.

What’s nice about this one is save_transparent_gif already uses List[Image] as the Type whereas the above comment one doesn’t.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why doesn't opacity changing animation work properly as a gif?
The GIF format only supports fully opaque or fully transparent pixels, but no intermediate levels of transparency. Essentially, what you are ...
Read more >
Problem with gif with transparent background - Stack Overflow
Your gif is disposal = 3 that means it needs previous image as it renders incrementally. The problem is the image is with...
Read more >
Aliased/jagged edges when creating animated gif with ...
I get a GIF file that works as expected, but on some backgrounds appears highly aliased. ... Gif does not support 8-bit transparency....
Read more >
Can I make a GIF with transparent background? - Help - Ezgif
Sure! Either delete the background from each frame manually before making a GIF (save the image as GIF or PNG to preserve transparency,...
Read more >
GIF Animator - transparent background issue - Alludo USER to ...
What it seems you are trying to do can't be done in the GIF format. You will need a background behind the text,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found