Skip to content

Optimize GIF encoding with max width scaling and color limiting#35

Open
grovecj wants to merge 1 commit intomainfrom
optimize-gif-encoding
Open

Optimize GIF encoding with max width scaling and color limiting#35
grovecj wants to merge 1 commit intomainfrom
optimize-gif-encoding

Conversation

@grovecj
Copy link
Copy Markdown
Owner

@grovecj grovecj commented Feb 23, 2026

Summary

  • Max width scaling (default 800px) — large captures are downscaled proportionally using lanczos resampling, never upscaled
  • Color palette limiting — wires up the existing colors config (default changed from 256 to 128) to ffmpeg's palettegen=max_colors
  • Bayer dithering — adds ordered dithering for better visual quality at reduced color counts; compresses better than floyd_steinberg in GIF format
  • Expected file size reduction: 70–80%

Configuration

Users can tune via config.json:

"encoding": {
  "colors": 128,
  "maxWidth": 800
}
  • colors: 16–256 (fewer = smaller files, lower quality)
  • maxWidth: 320–3840 (smaller = smaller files)

Test plan

  • Capture a large region (fullscreen on high-DPI) and compare file size to previous
  • Verify quality is acceptable at 128 colors / 800px
  • Test small capture (< 800px) is not upscaled
  • Test with colors: 256, maxWidth: 3840 for max quality

🤖 Generated with Claude Code

- Wire up the existing colors config (default reduced from 256 to 128)
- Add maxWidth setting (default 800px) to downscale large captures
- Use lanczos resampling for high-quality downscaling
- Add bayer dithering for better visual quality at reduced color counts
- These changes can reduce GIF file sizes by 70-80%

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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