Skip to content

Packs / game-assets-and-ai-public

game-sprite-cutout

Turn a generated image on a flat background into a clean game sprite: background removed, trimmed, optional pixel-art downscale and palette, padded to a power of two

Install

logicpacks pack use game-assets-and-ai-public/game-sprite-cutout
get_pack game-assets-and-ai-public/game-sprite-cutout

The second line is the MCP tool call for the LogicPacks connector (Claude Code, Codex, Claude.ai and others). The first run of a pack someone else wrote asks for your yes.

Keys it needs (names only)

None.

Playbooks included

  • Spec: spec/SPEC.md (goal, steps, edge cases, don’ts)
  • Routes: mfluxlocal-pillowcodex-image
  • Checks: 2 in outcome/checks.yaml
  • Code: make_fixture.pysprite_cutout.pyverify_sprite.py
  • Tools: python3, Pillow

Usage, last 8 weeks

New: no recorded use yet.

Purpose (from spec/SPEC.md)

Goal

A transparent PNG sprite ready for an atlas, from an AI image prompted onto a flat key colour.

Steps

  1. Generate on the free route with a flat key background: ~/gen-image.sh "<subject>, game sprite, centered, flat magenta #FF00FF background" raw.png.
  2. Cut out: python3 code/sprite_cutout.py raw.png sprite.png --key auto --tol 40 (flood fill from the corners, so key-coloured pixels inside the subject survive).
  3. Pixel art: add --pixel 64 --colors 16.
  4. Pack many sprites with sprite-atlas-packer.

Edge cases

  • Soft shadows on the background leave a halo: raise --tol or ask for 'no shadow' in the prompt.
  • Hair/fur edges: key-colour fringes; --despill pulls key colour out of edge pixels.

Don'ts

  • Don't use a background colour that appears in the subject.
  • Don't ship sprites of characters/brands we don't own.