sprite-gen README

The project's README from github.com/aldegad/sprite-gen. As one markdown file: README.md.

sprite-gen

One drawing in. Game-ready sprites out — as an atlas, or as transparent motion loops.

English · 한국어 · 日本語 · 简体中文 · Español · Français

Voting is open until October 5 (KST). sprite-gen is an entry in Wanted AI Championship 2026. If it has saved you time, a vote would mean a lot (Wanted login and a Korean phone check required).

Help cover the model API costs of developing sprite-gen with an optional GitHub sponsorship. Choose your amount and a one-time or monthly contribution.

Animated sprite-gen v2 showcase: paladin, wolf and slime

Each character started as one still image. Grok Imagine brought it to life; sprite-gen extracted the transparent loops, and HyperFrames assembled this showcase.

A samurai and companions walking through a painted village with layered scenery and projected shadows

A separate village composition made from sprite-gen assets. This GIF preserves the 10-second video at 20 fps with a 256-colour palette.


Ask an image model for a "sprite sheet" and you know what you get: a character whose face changes every frame, a background that won't key out, poses that overlap and drift off-grid, and a PNG your game engine can't actually consume. Cute demo, useless asset.

sprite-gen is a Codex/Claude skill and a Python CLI that closes that gap. Give it one base image — it drives generation row by row, locks the character's identity, strips the chroma background to real alpha, extracts each pose as a clean transparent frame, and bakes a runtime atlas with a machine-readable manifest.json.frame_layout. Or hand the same still to a video model and get back a seamless, transparent loop per motion state. For the last 10% that generation never gets right, a curation webview lets you compare, reject, nudge and watch the loop live before you bake.

For side sprites, video-set uses --facing right|left consistently across canvas placement and clip prompts. Its direction detector is record-only by default (--facing-fix none) and can be wrong even at high confidence. Use gen --ref image.png --facing right to request orientation in the generation prompt; gen otherwise preserves orientation. Prompts request direction but cannot guarantee the result. Correction is opt-in: --facing-fix mirror, or gen --facing-fix regen; review the still before using either. See facing options.

Samurai Claudecy two-handed katana cut loop Samurai Claudecy one-handed katana cut loop Slime attack loop Hooded fox attack loop Paladin attack loop

v2.5.3 attack loops straight out of the video pipeline: one still each, Grok Imagine clip, frames gate, automatic loop selection. No manual cut points.

Start with a request

Ask for sprites or an image. The agent checks access, asks only for missing provider/motion choices, runs the existing pipeline, and delivers the files. The curation view is optional. Save your choices once to reuse separate sprite and image defaults; a one-off request does not overwrite them. User workflow and defaults.

Pipelines, independent tools and scenes

The two sprite pipelines are ordered generation flows. Tool groups contain independent commands; scene creation is an optional workflow that consumes finished assets. sprite-gen --help prints this map and groups commands by the code domain that owns them.

flowchart LR
    subgraph A["A · atlas rows"]
        direction LR
        a1[prepare] --> a2["gen · gen-set"] --> a3[extract] --> a5[compose-atlas]
        a5 -.-> a4["curation (optional)"]
        a4 --> a5
    end
    subgraph B["B · video → loop"]
        direction LR
        b1[video-canvas] --> b2[video] --> b3[video-frames] --> b4[video-loop]
    end
    subgraph C["C · utilities"]
        direction LR
        c1[cutout] ~~~ c2[slice-sheet] ~~~ c3[unpack-atlas]
    end
    subgraph D["D · post-processing"]
        direction LR
        d1[recolor] ~~~ d2[compose-layers] ~~~ d3[export-*]
    end
    subgraph E["E · asset tools (independent)"]
        e1[background-tile] ~~~ e2[shadow] ~~~ e3[inspect-motion]
    end
    subgraph S["S · scene (optional)"]
        s1["existing assets + scene.json"] --> s2[scene-render]
        s1 --> s3[scene-inspect]
    end
Pipeline / tool group / workflow What goes in → what comes out Docs
A · atlas rows one still + a list of states → sprite-sheet-alpha.png + manifest.json.frame_layout, with Breathe baked on idle poses run-contract · breathing
B · video → loop one still → per state, a seamless transparent GIF / WebP / strip, animated by Grok Imagine and cut at its true period video-pipeline · video
C · utilities an imported image or grid sheet → clean transparent cuts; a finished atlas → a curator-ready run sheet-slicing · curation
D · post-processing a finished sheet → deterministic colourways, rig layer composites, Aseprite / Phaser / Flame exports recolor · layer-tracks · engine-export
E · asset tools independent PNGs or animations → repeating tiles, projected shadows, motion/contact measurements asset-tools
S · scene existing assets + placement, camera and lighting → PNG frames, MP4/GIF, inspection and placement metadata scene

Full index: docs/README.md. Architecture with domain and pipeline diagrams: docs/architecture.md.

What you actually get

Quickstart

# install (Pillow, NumPy) into a fresh virtualenv — the venv is the only supported interpreter
python3 -m venv .venv && source .venv/bin/activate
pip install -e .
sprite-gen --help

A · atlas rows — one still to a runtime atlas.

sprite-gen prepare --out-dir <run> --character-id <id> --base-image base.png   # request, guides, prompts
sprite-gen gen-set --run-dir <run> --provider codex                            # every state row, 4 at a time
sprite-gen extract --run-dir <run>                                             # chroma → transparent frames
sprite-gen compose-atlas --run-dir <run>                                       # sprite-sheet-alpha.png + manifest.json
sprite-gen curation --run-dir <run>                                            # (optional) pick, nudge, breathe

B · video → loop — one still to transparent loops (needs ffmpeg, img2webp, and your own grok login or XAI_API_KEY).

sprite-gen video-set --base side=still.png --states idle,walk,run,jump,attack --out-dir set/
# per item: video-canvas → video → video-frames → video-loop; set/table.md names every result

C · utilities — each stands alone.

sprite-gen cutout icon.png --white-check              # white/ivory → matte, magenta/green → chroma engine
sprite-gen slice-sheet --sheet sheet.png --chroma-key magenta --grid 3x2   # multi-figure sheet → per-cell cuts
sprite-gen unpack-atlas --atlas sheet.png             # finished atlas → curator-ready run (or --pngs-dir folder/)

D · post-processing — refine a finished sheet without regenerating.

sprite-gen recolor-palette --base <run>/sprite-sheet-alpha.png --out palette.draft.json
sprite-gen recolor --run-dir <run> --spec recolor.spec.json      # → <run>/variants/
sprite-gen compose-layers --run-dir <run>                        # rig runs: declared stacks → <run>/layers/
sprite-gen export-aseprite --run-dir <run>                       # Aseprite JSON for Phaser / Flame

E · asset tools — each accepts existing assets, including artwork from other tools.

sprite-gen background-tile --source background.png --period 512 --overlap 32 --out tile.png
sprite-gen shadow --source walk.strip.json --out-dir shadows/
sprite-gen inspect-motion --source walk.strip.json --out motion.json
# Only with known same-foot contact and an isolated foot ROI:
sprite-gen inspect-motion --source walk.strip.json --contacts 0:4 --foot-box 20,70,32,10 --out stance.json

S · scene — an optional composition workflow. The scene contract includes a complete spec.

sprite-gen scene-render --spec scene.json --out-dir render/ --formats png,mp4 --export-layers
sprite-gen scene-inspect --spec scene.json --out scene-check.json

The agent-facing workflow, gates and contracts live in SKILL.md.

Install as a skill

python3 ~/.codex/skills/.system/skill-installer/scripts/install-skill-from-github.py \
  --repo aldegad/sprite-gen --path . --name sprite-gen

Image generation is part of this engine (sprite_gen.gen, providers codex and grok on a subscription you already pay for, plus an explicit-only openai provider for servers and SaaS that bills per call; the general image-gen skill is a thin shuttle over it). Video uses your own credential — the grok CLI login or an XAI_API_KEY — and nothing is shipped with the repo (docs/video.md).

sprite-gen supports CPython 3.11+; CI runs only 3.14. Python 3.10 is no longer supported. The quickstart needs a Python with working venv/ensurepip.

Attribution

The component-row workflow is inspired by the Apache-2.0 licensed hatch-pet skill, but targets generic game sprite atlases and includes no pet packages or pet visual assets.

Community contributions, experiments, and their originating pull requests are documented in CONTRIBUTORS.md.

License

Apache-2.0

sprite-gen (aldegad/sprite-gen)

Searching Database…

这是什么?sprite-gen 把一张基础图片变成可直接用于游戏的 2D 精灵图集或透明循环动画,以 Codex/Claude 编码 agent 技能加独立 Python CLI 的形式打包。
这是一个工具,还是多个管线打包在一起?它打包了 atlas-rows 管线(静态图到精灵表)、video-to-loop 管线(静态图到透明动画)、相互独立的工具组和后处理工具组,以及一个可选的场景合成工作流;`sprite-gen --help` 会说明哪些命令属于哪个部分。
怎么开始生成精灵图?把一张基础图片输入 atlas-rows 管线(`gen`),得到 sprite-sheet-alpha.png 及其 manifest.json.framelayout;建议先运行 `sprite-gen --help` 查看所有管线组,或者把它安装为 Codex/Claude 技能,让你的 agent 调用同样的命令。
video-to-loop 管线需要什么?图集管线只需要 Python 3.11+ 和可用的 venv/ensurepip;而 video-to-loop 管线还需要 ffmpeg、img2webp,以及你自己的 grok CLI 登录或一个 XAIAPIKEY,因为仓库本身不带视频生成能力。
朝向/方向检测总是准确吗?不一定——方向检测器默认只做记录,即使报告高置信度也可能出错;用 --facing-fix mirror 或 --facing-fix regen 修正是可选操作,使用前应先人工确认。
什么是 Breathe?Breathe 只凭一个 sidecar 字段,就把确定性的挤压拉伸(squash-and-stretch)烘焙到你精选的帧上,把静态的待机姿势变成鲜活的循环动画,同时保持解剖结构合理、像素级还原。
sprite-gen 用哪些图像和视频服务商?图像生成由 codex 和 grok 服务商完成,绑定你已经在付费的订阅;另有仅限显式指定的 openai 服务商供服务器使用;动态循环由 Grok Imagine 生成,使用你自己的 grok CLI 登录或 XAIAPIKEY。
可以把完成的图集导出到游戏引擎吗?可以,后处理阶段支持导出 Aseprite、Phaser 和 Flame 格式,还支持确定性的重新着色变体和骨骼层合成。
为什么不直接让图像模型生成精灵表?直接生成会带来姿势漂移、各帧面部不一致、背景抠不干净等问题;sprite-gen 则驱动逐行生成、锁定角色一致性,并剥离出真正的 alpha 通道,让结果能真正被游戏引擎使用。
Creator
aldegad
Size
62.3 MB
Stars
2.9K
Age
5mo
Commits · 90 Days