The "my beloved" heart locket GIF has been a staple reaction format since 2020: a glossy red locket swings open to show a photo on one side and a caption on the other. I built a heart locket GIF maker that generates these entirely in the browser β no upload, no server-side rendering.
Disclosure: that's my own project. Everything below works with plain Canvas and a GIF encoder; nothing here depends on it.
The interesting parts turned out to be the ones I didn't expect: GIF's one-bit transparency, palette drift across frames, and deciding what belongs on a worker and what doesn't.
The shape: a heart as a clipping path
No image assets. The locket is drawn in code, which means it scales to any output size and recolours without a sprite sheet.
A heart is two bezier curves meeting at a point:
function heartPath ( ctx , cx , cy , width , height ) { const top = height * 0.3 ; ctx . beginPath ( ) ; ctx . moveTo ( cx , cy + top ) ; ctx .β¦