Skip to content

Fix RGBA color handling in truecolor mode#1

Open
Felixdiamond wants to merge 2 commits into
telnet23:masterfrom
Felixdiamond:master
Open

Fix RGBA color handling in truecolor mode#1
Felixdiamond wants to merge 2 commits into
telnet23:masterfrom
Felixdiamond:master

Conversation

@Felixdiamond
Copy link
Copy Markdown

@Felixdiamond Felixdiamond commented Nov 9, 2024

Fix RGBA color handling in truecolor mode

Problem

When using truecolor mode (--mode truecolor), the application crashes with a ValueError: too many values to unpack (expected 3) error when processing GIFs that contain RGBA color data. This occurs because some GIFs contain alpha channel information (RGBA format) but the color processors expect RGB format. Plus it loops forever

Solution

Modified the color processors to safely handle both RGB and RGBA color inputs by taking only the first three color components (RGB). This maintains compatibility with existing GIFs while adding support for RGBA GIFs.

Changes made:

  • Added color[:3] slicing in all processor pre() methods to consistently handle RGB values
  • Add loop functionality

Testing

Tested with:

  • RGBA GIFs from Tenor
  • Standard RGB GIFs
  • Both local and remote GIFs
  • Different terminal color modes (ascii, 256color, truecolor)

Before (with RGBA GIF):

ValueError: too many values to unpack (expected 3)

After (with RGBA GIF):

  • Displays correctly in truecolor mode
  • Maintains correct color representation
  • Smooth animation playback

Impact

This change:

  • ✅ Fixes crashes with RGBA GIFs
  • ✅ Maintains backward compatibility
  • ✅ No performance impact
  • ✅ No new dependencies
  • ✅ Preserves original code structure
  • ✅ Add loop feature

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.

1 participant