Export Sprite Sheet
From Poses to a Game-Ready PNG
- images
- spritesheet
- png_path
- json_path
You've generated a batch of frames - your hero idling, walking, running, fighting. Now you want them as an actual sprite sheet: one PNG with all the frames in a grid, plus metadata a game engine can parse. CP_ExportSpriteSheet is the last node in that pipeline. It takes an IMAGE batch, lays the frames out in a grid, writes the PNG, and dumps a JSON describing every cell.
How it works
It takes each frame in your batch, computes the grid layout from columns, pads each cell by padding pixels, and writes the result to ComfyUI/output/spritesheets/<filename>.png with a matching .json next to it. The JSON records the sheet dimensions, frame count, per-frame width/height, and a frames array with cell positions and labels.
The optional labels input is one label per line, applied to the frames in order. Leave it empty and you get frame_00, frame_01, ... - fine for a quick export, slightly sad for an actual game.
The inputs that matter
- images - the batch. Any
IMAGEtensor with a batch dimension: theskeletonsoutput of the sheet generators, a batch of rendered characters, whatever. - filename - default
spritesheet. A trailing.pngis stripped automatically. - columns - frames per row (default 4).
- padding - gap between cells in pixels (default 0). Give it a few pixels if your frames have edges that bleed into each other.
- labels - one per line, optional.
Outputs: spritesheet (the composed grid as an image, if you want to preview it), png_path, and json_path - the absolute file paths, ready to feed a "load this file" node or just to read in your file browser.
Installing
It's in the same pack as everything else here:
cd ComfyUI/custom_nodes
git clone https://github.com/Spit8/_ComfyUI_CharacterPose
pip install -r _ComfyUI_CharacterPose/requirements.txt
Restart ComfyUI; look under CharacterPose/Sheet. It's an output node - it saves files, so remember it won't appear in a "everything after me is a preview" sense.
Gotchas
- All frames must be the same size - the grid takes its cell dimensions from the first frame. Mixing resolutions produces a broken sheet.
- Frames are assumed square-ish in practice; a grid of 4 columns with 14 frames gives you rows of 4/4/4/2, which is fine but looks lopsided. Pick
columnsthat divide your frame count if you care. - The sheet is saved to
output/spritesheets/, not the default output folder. If you can't find your PNG, that's where it went. - It writes PNG + JSON but doesn't auto-open anything - wire the
spritesheetoutput to a preview node if you want to eyeball the layout.
Grid the frames, write the metadata, done. The last five minutes of a sprite-sheet pipeline, wrapped in one node.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| images | IMAGE | — | |
| filename | STRING | spritesheet | — |
| columns | INT | 41–32 | — |
| padding | INT | 00–64 | — |
| labelsopt | STRING | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| spritesheet | IMAGE | — |
| png_path | STRING | — |
| json_path | STRING | — |