sprite-gen Tutorial: Turn a Character Image into a Sprite Sheet
Open-source sprite-gen turns one image into a sprite sheet. Chibi knight walk and sword-swing tests with images and Grok video, plus setup.

Animating a character for a 2D game means drawing every pose of every move, one frame at a time, and laying them out on a sprite sheet that the game slices up and plays back. Simply asking an image AI to "draw a sprite sheet" rarely gives you something usable: the face changes from frame to frame, the background never comes off cleanly, the poses wobble out of alignment, and the game engine has no idea where each frame is.
sprite-gen was built to fix exactly these problems. I installed it, designed an original chibi knight from scratch, made him walk and swing a sword, and then played the animation in a small web game. I tested both the image mode and the Grok video mode. This post covers installation, the exact commands I ran, the results, and the trap you must avoid in video mode.
What is sprite-gen?
sprite-gen is an open-source Python command-line tool that is also a skill Codex and Claude Code can load. Give it one character image and it will:
- Have an image AI draw each move as its own row, while keeping the character’s appearance consistent;
- Remove a solid background such as a green screen and turn it into real transparency;
- Cut each pose into clean, transparent frames;
- Assemble an atlas (
sprite-sheet-alpha.png) with amanifest.jsonthe game can read, listing each frame's coordinates, playback speed, and whether it loops.
The details below were checked on 2026-11-23:
Item | Details |
|---|---|
Developer | aldegad (GitHub) |
License | Apache-2.0 |
Form | Python command-line tool, also a Codex / Claude Code skill |
Python | 3.11 or later |
Drawing AI | codex (sign in with a ChatGPT account), grok (xAI), openai (API key, pay per request) |
Output | Transparent atlas, |
Export | Aseprite JSON (for Phaser and Flame), individual PNGs |
What can sprite-gen do? Two main pipelines
sprite-gen has two pipelines for making animation, plus a few small tools you can use on their own:
Pipeline | Input → output | AI used |
|---|---|---|
A · Atlas (atlas rows) | One character image + list of moves → transparent sprite sheet + | Image AI (codex, grok or openai) |
B · Video to loop | One character image → a transparent looping animation per move (GIF, WebP, strip) | Grok Imagine video |
Small tools | Background removal ( | No AI needed |
I tested both pipelines for this post. Pipeline A only needs an image AI; with codex, it uses your ChatGPT account’s quota, so there's no separate API to sign up for. Pipeline B uses Grok's video generation: sign in with the grok command-line tool and it counts against your SuperGrok Imagine quota; only when you're not signed in does it fall back to a pay-per-request xAI API key.
There's also a "curation" interface (curation) that opens a web page where you can compare, delete and fine-tune each frame, watch the loop play, and rebuild the atlas. This step is optional.
How to install sprite-gen
The only officially supported installation method uses a virtual environment (venv):
git clone https://github.com/aldegad/sprite-gen
cd sprite-gen
python3 -m venv .venv && source .venv/bin/activate
pip install -e .
sprite-gen --helpThen sign in to the image AI you want to use. For codex, run codex login once in the terminal and sign in with your ChatGPT account.
Using it as a skill for an AI coding assistant
The sprite-gen folder includes a SKILL.md, so an AI coding assistant (agent) can drive it for you:
- Codex: there's an official install command:
python3 ~/.codex/skills/.system/skill-installer/scripts/install-skill-from-github.py \
--repo aldegad/sprite-gen --path . --name sprite-gen
- Claude Code: put the whole folder in
~/.claude/skills/sprite-gen/, with its.venvset up inside as well.
The skill finds the install location through the SPRITE_GEN_ROOT environment variable (set it to the folder's full path first), and always runs the Python inside .venv, never the system Python. After that, just tell the agent "turn this character image into a walk and attack sprite sheet" and it follows the skill's workflow step by step.
Hands-on: an original chibi knight that walks and swings a sword
Here are the steps I actually followed. Going from one image to a sprite sheet ready for a game takes only a few commands.
1. Draw a base character image
sprite-gen needs a "final" full-body standing pose as the base image; every move is matched against it. I didn't have a character ready, so I used sprite-gen's gen command to have codex draw one:
sprite-gen gen --provider codex --direction side --facing right --transparent \
--out base.png \
--prompt "Original cute chibi knight character for a 2D side-scrolling game, full body, standing idle pose. Big round head, rounded silver helmet with the visor raised showing a cheerful face, a short orange plume on top. Silver armor with a royal blue tabard bearing a simple white star, short dark blue cape, brown leather boots. Holding a short silver sword pointing down, no shield. Clean bold dark outlines, flat cel shading, hand-painted 2D game sprite style."--direction side --facing right asks for a side view facing right; when the character walks left in a side-scroller, just flip the image horizontally. --transparent outputs a transparent background directly.

I think this knight design works; it's fine to use as a game character as is.
2. Define the moves
Moves go in request.json: the frame size, how many frames each move has, frames per second, whether it loops, and an English description of the move.
{
"cell": { "width": 256, "height": 256 },
"states": {
"walk": {
"frames": 6, "fps": 10, "loop": true,
"action": "side-view walk cycle to the right: legs alternate stepping, arms swing gently, sword held low in the front hand, cape flutters slightly"
},
"attack": {
"frames": 5, "fps": 10, "loop": false,
"action": "sword swing to the right: raise the sword overhead, swing it down and forward in a big arc, sword extended forward low, then return to the idle stance; feet stay planted, no detached slash effects"
}
}
}The official advice: one-shot moves like attacks and jumps are most reliable at 4 to 6 frames. Looping locomotion such as walk cycles and runs is marked "experimental", because image AI still can't reliably get the left and right feet to alternate.
More frames aren’t necessarily better either. In the official tests, 9 or 12 frames tended to produce duplicated bodies, empty cells, or frames that couldn't be separated.
3. Generate, remove the background, build the sprite sheet
sprite-gen prepare --out-dir run --character-id chibi-knight \
--base-image base.png --request request.json
sprite-gen gen-set --run-dir run --provider codex
sprite-gen extract --run-dir run
sprite-gen compose-atlas --run-dir run
sprite-gen compose-gif --run-dir run --out-dir run/previewsprepare: automatically picks the background color that contrasts most with the character (green this time), writes the AI prompt for each move, and generates a layout guide image marking where each frame goes.gen-set: asks codex to draw one strip per move, with several moves running at the same time. My walk and sword swing were drawn in parallel, taking about 41 and 43 seconds.extract: removes the green screen, finds each pose, and cuts it into transparent frames.compose-atlas: builds the sprite sheet andmanifest.json.compose-gif: outputs a preview GIF for each move so you can see it in motion right away.
Background removal, slicing and atlas assembly together take just a few seconds; the whole pipeline finishes in under 1 minute.
Here's the sword-swing strip codex drew, on the green screen prepare chose:

Here is the assembled sprite sheet after background removal and slicing: the top row is the 6-frame walk, the bottom row the 5-frame sword swing, each frame 256×256.

I checked every frame; I think the walking steps and the force of the sword swing are acceptable.
4. Play it in a game
In manifest.json, frame_layout holds each frame's coordinates on the atlas, and animation holds how long each frame lasts and whether it loops. The game just reads them, so you never have to guess how to slice the grid:
"frame_layout": {
"sheetWidth": 1536, "sheetHeight": 512,
"rows": {
"walk": [{ "x": 0, "y": 0, "w": 256, "h": 256 }, …],
"attack": [{ "x": 0, "y": 256, "w": 256, "h": 256 }, …]
}
}I wrote a small web demo: the knight walks left and right, swings his sword when you press the space bar, and goes back to walking when the swing ends. The core is just a few lines of JavaScript:
const M = await (await fetch("run/manifest.json")).json();
const sheet = new Image();
sheet.src = "run/" + M.sprite_sheet_alpha;
// Each tick: advance frames by durations_ms; a loop:false action returns to walk when done
const a = M.animation.rows[state];
t += dt * 1000;
while (t >= a.durations_ms[frame]) {
t -= a.durations_ms[frame];
frame++;
if (frame >= a.frames) {
if (a.loop) frame = 0;
else { state = "walk"; frame = 0; break; }
}
}
// Cut this frame out of the atlas and draw it; flip horizontally when walking left
const r = M.frame_layout.rows[state][frame];
ctx.save();
ctx.translate(x, 0);
if (dir < 0) ctx.scale(-1, 1);
ctx.drawImage(sheet, r.x, r.y, r.w, r.h, -r.w / 2, groundY + M.cell.safe_margin_y - r.h, r.w, r.h);
ctx.restore();Each frame has a safety margin at the bottom (safe_margin_y, 24 px this time). When drawing, account for this margin in the vertical position so the knight's feet stand on the ground.
Video mode test: 2D character animation with Grok Imagine video generation
In image mode, a move has only 5 or 6 frames, so it looks choppy. Pipeline B takes a different approach: hand the base image to Grok Imagine to film a short clip of the character moving, then sprite-gen cuts exactly one loop out of the video, at 24 frames per second.
Install two tools first
- img2webp: needed to output transparent animated WebP. On Arch Linux it's in the
libwebp-utilspackage (sudo pacman -S libwebp-utils); on macOS, installwebpwith Homebrew. - RIFE: a frame interpolation tool, used to fix walk and run loops that don't join smoothly, as well as repeated frames. Install it with sprite-gen's own command; the download is about 830 MB, and only a few dozen MB remain after installation:
sprite-gen rife installYou also need ffmpeg, and you should sign in first with grok login.
The base image can't have a transparent background
This is the easiest trap to fall into. The video pipeline reads the colors at the four corners of the base image to decide the background color. If the base image is transparent, the transparent areas are sent to filming as black, but during background removal they're judged as white.
As a result, the knight's light silver armor gets cut away as background: floating fists, broken shins and jagged edges.

The fix is to place the character on a pure green (#00FF00) background first, then add --key green:
sprite-gen video-set --base side=base-green.png --facing right --key green \
--states walk,attack \
--motion "attack=raises the sword overhead, swings it down and forward in a big arc, then returns to the idle stance; feet stay planted, no slash effects" \
--out-dir vsetvideo-set runs everything in order: places the base image on a canvas suited to each move (a wider one for the attack), asks Grok to film, removes the background, finds the loop point, and interpolates frames. The walk clip defaults to 3 seconds and the attack to 2 seconds; both are filmed at the same time, and the whole pipeline takes about 5 minutes.
Video mode results
- Walk: 27 frames, exactly one step with each leg. The cape flows along, and every transition between steps is there.
- Sword swing: 48 frames, 2 seconds. It starts from the standing pose, extends the sword forward, raises it overhead and back to wind up, swings it down and forward in a big arc, then sheathes the sword and returns to the standing pose.

The downsides are obvious too: during the swing, Grok draws the sword longer and longer, up to roughly twice its original length. That comes from the video model, and sprite-gen can't fix it. Also, sprite-gen counts the raised sword when measuring the character's height, so the character in the sword-swing frames ends up smaller than when walking. When you put them in a game, align them yourself by the standing height.
Image mode vs video mode
Same knight, same walk. Image mode on top, video mode below:
Image mode (pipeline A) | Video mode (pipeline B) | |
|---|---|---|
AI used | codex (ChatGPT subscription) | Grok Imagine (SuperGrok quota) |
Walk | 6 frames | 27 frames |
Sword swing | 5 frames | 48 frames |
Motion | Abrupt pose changes | Full, continuous transitions |
Generation time | Under 1 minute | About 5 minutes |
Watch out for | Walk is an "experimental" move | Base image can't be transparent; the sword grows |
Output | sprite sheet + | One strip + JSON, GIF, WebP per move |
Side by side, the biggest difference is the cape. When the video-mode knight walks, the cape moves very naturally; I think it holds up against finished work from major studios.
Can you use the walk cycle as is?
Walking and running are officially "experimental", and the docs require checking every move by playing the animation, not just looking at single frames:
- Looping moves (walk, run): should look like continuous forward motion, not bobbing in place; the last frame should flow smoothly back into the first.
- One-shot moves (attack, jump): should have a clear start, middle and end.
- Humanoid characters: joints like knees and elbows, and the hands, are the easiest to break. Check every frame for extra or missing limbs and arms that change length.
If a move fails, the official approach is to regenerate the whole row, not to hand-fix frames or tweak playback speed to hide the problem. For this knight, the image-mode walk alternates left and right legs across its 6 frames, and the 5-frame swing is a complete sequence of raising, swinging and sheathing the sword. If you want a smoother walk, the 27-frame video mode is another option.
For this knight, I think the image-mode walk can go straight into the game.
sprite-gen's downsides
After actually using it, there are quite a few things worth knowing up front:
- Motion quality depends on the drawing AI. sprite-gen handles background removal, slicing and atlas assembly. The motion itself is generated by the image or video AI, and problems in the motion can't be fixed by sprite-gen. In image mode, 4 to 6 frames per move is recommended, 8 at most; in the official tests, 9 or 12 frames tended to break. This time the image-mode swing never raised the sword behind the head to wind up, so it looks more like a forward thrust. Video mode, meanwhile, keeps drawing the sword longer.
- Video mode has many steps and is error-prone. The base image can't have a transparent background, the sword-swing frames get scaled down, and generation takes several minutes. When something goes wrong, you only find out why from the warnings in the terminal, which isn't very beginner-friendly.
- Lots of features, hard-to-read docs. Beyond sprites, it also does talking-face layers (lip sync), scene compositing, title-text logos, and video clip extension and editing. The docs are dense, some sections are still in Korean, and on a first read it's hard to find the part you need.
- Very frequent changes. The project moves fast and commands and options change often. Before following any tutorial online (including this one), run
sprite-gen --helponce to confirm the commands still exist. - Limited choice of drawing AI. Images can only use codex, grok or openai, and video only supports Grok Imagine. Without a ChatGPT or SuperGrok subscription, you're left with pay-per-request APIs.
- Basic Claude Code support. There's only an official install command for Codex; for Claude Code you have to put the folder in the skills directory yourself.
Does sprite-gen cost money?
sprite-gen itself is free and open source; the cost depends on which AI does the drawing:
- codex: sign in with your ChatGPT account and it counts against your existing subscription quota. It's the default if you don't specify one.
- grok: after you sign in with the grok command-line tool, it uses your SuperGrok Imagine quota (video mode films one clip per move); only when you're not signed in does it use
XAI_API_KEY, billed per request. - openai: uses
OPENAI_API_KEY, billed per request, and only when you explicitly choose it.
Whenever an API key is involved, sprite-gen warns you in the terminal that "this will be billed" before sending the request. If codex is unavailable (not signed in or out of quota), by default it stops and asks which one to use instead, rather than quietly switching to a paid API.
How is it different from asking AI to draw a sprite sheet?
Asking an image AI directly | sprite-gen | |
|---|---|---|
Character look | Often changes from frame to frame | Every move is sent with the same base image to lock the look |
Background | Often white or a checkerboard that won't come off cleanly | Picks a green-screen color automatically; real transparency after removal |
Frame position | Skewed, overlapping, inconsistent sizes | Finds each pose, aligns the feet, and fits it into a fixed-size cell |
How the game reads it | Measure coordinates yourself |
|
Checking | Eyeball it yourself | A preview GIF and a validation report for each move |
The AI only handles the "drawing" step. Background removal, slicing and atlas assembly are fixed program steps; for these steps, the same input always gives the same result.
If you want to read about my experience making a 3D game with AI, see the Dream Loop workflow for making games with AI and a comparison of Blender scripts and Tripo AI for 3D characters.
FAQ
Is sprite-gen free? Can I use it commercially?
sprite-gen is open-source software under the Apache-2.0 license, free to use and fine for commercial projects. The drawing AI is billed separately: codex counts against your ChatGPT subscription, while API keys are billed per request.
What is a sprite sheet?
A sprite sheet is a single image holding the frames of a character's moves, which the game slices out using their coordinates and plays back. Besides the image, sprite-gen also outputs a manifest.json recording each frame's coordinates and timing.
Do I have to use Claude Code or Codex with sprite-gen?
No. It's a command-line tool in its own right, and you can run it yourself in the terminal. Installing it as a skill in Claude Code or Codex just lets an AI coding assistant run those commands for you.
Can it make pixel art characters?
Yes. sprite-gen has pixel art handling: it measures the size of the character's pixel grid so every frame aligns to the same grid, so you don't get fake pixels of different sizes. The base image itself has to be pixel art, though; changing the prompt won't turn another art style into pixel art.
What if my walk cycle looks off?
In the official docs, walking and running are "experimental" moves. If one fails, the official advice is to regenerate the whole row rather than fix frames by hand. You can also switch to pipeline B: have Grok film a walking clip, and sprite-gen automatically cuts out a loop of exactly two steps. My knight came out at 27 frames, far smoother than the 6 frames in image mode. With pipeline B, put the base image on a green background first; a transparent background won't work.
Can I import the finished sprite sheet into Aseprite or a game engine?
manifest.json is plain JSON that any engine or web page can read. sprite-gen can also export Aseprite-format JSON for engines like Phaser and Flame to use directly.
Wrapping up
sprite-gen breaks "ask AI to draw a sprite sheet" into a series of fixed steps: the AI only draws, and the code handles background removal, slicing, alignment and atlas assembly.
Starting from one knight base image, image mode gave me walk and sword-swing animations in under 1 minute, ready to use in a game. Video mode takes a few more minutes and uses some Grok quota, and the motion is much smoother; but the base image has to go on a green background first, and you have to check the sword's length yourself.
Still, turning one image into a moving character is just one stop on the way to making a game. From character design, animation and sound effects to getting everything into the game, I'm connecting a whole game-design pipeline piece by piece, and I'll be sharing more practical tips along the way.
To be the first to see the next post, follow me on Threads and X. If you're making 2D game characters too, leave a comment and tell me how you do it.


