Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@skidder
Copy link
Contributor

@skidder skidder commented Jun 3, 2025

Summary

Fixes a color corruption issue in animated GIFs where frames with local color palettes would display incorrect colors in Discord and other viewers.

Problem

The issue was introduced in commit 52ba7f4 where transparency optimization logic incorrectly compared color indices from different color maps:

  • gcb.TransparentColor refers to an index in the current frame's color map (local or global)
  • e->gif->SBackGroundColor refers to an index in the global color map

When a frame used a local color map, these indices could point to completely different colors, but the code incorrectly assumed they referenced the same palette. This caused transparency to be incorrectly removed, leading to visible color corruption.

Solution

Added a check !e->frame_color_map to only perform the transparency optimization when using the global color map, preventing index mismatches between local and global palettes.

Testing

  • All existing tests pass
  • Verified fix with the problematic GIF reported by Discord users
  • Re-encoded GIFs now display correctly without color corruption

Files Changed

  • giflib.cpp: Added palette type check in transparency optimization logic

Resolves the regression reported by Discord users where GIFs processed by Lilliput showed "colors completely warped, flashing wildly" during playback.

@skidder skidder marked this pull request as ready for review June 3, 2025 16:17
@skidder skidder merged commit 48d1d17 into master Jun 3, 2025
5 checks passed
@skidder skidder deleted the skidder/fix-gif-palette-corruption branch June 23, 2025 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants