Skip to content

Stabilize GIF and GIF emoji frame grids#63

Draft
achimala wants to merge 1 commit into
mainfrom
cursor/gif-frame-grid-stability-79b0
Draft

Stabilize GIF and GIF emoji frame grids#63
achimala wants to merge 1 commit into
mainfrom
cursor/gif-frame-grid-stability-79b0

Conversation

@achimala

@achimala achimala commented Jun 4, 2026

Copy link
Copy Markdown
Owner

Summary

GIF and GIF emoji frames were jiggling because the image model does not lay out sprite sheets on a perfectly even grid, and each frame was resized independently with fit: "contain".

This change stabilizes animation output in processGifEmojiGrid (used by /gif, /gifemoji, and agent GIF generation).

Changes

  • Grid boundary detection: Scan vertical and horizontal edge profiles near expected split positions to find real frame seams instead of using floor(width / gridSize) for every cell.
  • Content alignment: After magenta keying, crop each frame to its foreground bounds, apply one shared scale across all frames (based on the largest content size), and center every frame on the 128×128 output canvas.

Testing

  • pnpm lint
  • pnpm build
Open in Web Open in Cursor 

Detect imprecise frame grid boundaries via edge profiles instead of
naive equal splits. Crop each cell to its content, scale all frames with
a shared factor, and center them on the output canvas to stop jiggle.

Co-authored-by: Anshu Chimala <achimala@gmail.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.

2 participants