Nodes/Link Comfy Nodes/Spritesheet Builder
ComfyUI Node

Spritesheet Builder

Pack a frame batch into one sheet at a target aspect ratio

By Mister-Link·Created 9 months ago·Updated 24 days ago· 0
Spritesheet Builder
  • frames
  • alpha
  • spritesheet
  • alpha
  • metadata
aspect_ratio

The classic pixel-art and game-dev output step: instead of exporting hundreds of loose individual frames, you want one image - a grid of every frame in your animation - sized to whatever aspect ratio your engine or tool actually expects. Spritesheet Builder takes a rendered animation batch and tiles it into a single sheet, picking a grid layout that fits your chosen aspect ratio rather than forcing a fixed row/column count on you.

The inputs and outputs that matter

  • frames - your animation batch.
  • alpha - the accompanying transparency. Sprite work is almost always meant to composite over something else rather than sit on an opaque background, so this is required, not optional.
  • aspect_ratio - one of five choices: 1:1 (Square), 4:3 (Landscape), 3:4 (Portrait), 16:9 (Landscape), 9:16 (Portrait). This sets the overall shape of the finished sheet; the node works out the grid arrangement to fit it.

Outputs: spritesheet (the assembled image), alpha (the sheet's combined transparency, aligned to the same grid), and metadata (a string). That metadata output is the piece worth paying attention to - it's almost certainly carrying the layout information a game engine or spritesheet reader needs to slice the sheet back into individual frames (frame count, grid dimensions, per-frame size). Preview it with this pack's own Preview as Markdown node if you just want to read it, or save it alongside the image for your asset pipeline to consume.

How it fits with the rest of the pack

This sits at the end of a natural chain: quantize or palette-map your frames first (Pixelate or Palettize, both in this pack), decide your target resolution with Sprite Scale Calculator, then bring everything together here into one exportable sheet.

How to install it

Search "Link Comfy Nodes" in ComfyUI Manager and install from there. Or by hand:

cd ComfyUI/custom_nodes
git clone https://github.com/Mister-Link/link-comfy-nodes
pip install -r link-comfy-nodes/requirements.txt

Restart ComfyUI. No extra models or heavy dependencies for this node specifically.

Common issues & troubleshooting

frames and alpha batch sizes don't match. Both need to line up frame-for-frame going in - a mismatch is likely to error or, worse, produce a spritesheet whose alpha channel doesn't correspond to the right cells. Check your batch counts before wiring this up.

Frame count doesn't divide cleanly into your chosen aspect ratio. If your batch size doesn't tile neatly into a tidy grid for the aspect_ratio you picked, expect the node to pick the closest reasonable fit rather than a mathematically perfect one. Don't assume a specific row/column layout - check the metadata output to see exactly how it actually laid the frames out before you build a game-engine importer around an assumed grid.

Building an importer around guessed dimensions. Since metadata is the authoritative source for frame size and grid layout, parse it programmatically on the receiving end rather than hardcoding numbers you eyeballed from one export - the grid shape can change if your frame count or aspect ratio choice changes later.

Categoryimage/transform

Inputs (3)

NameTypeDefaultDescription
framesIMAGE
alphaMASK
aspect_ratioCOMBO5 options: 1:1 (Square), 4:3 (Landscape), 3:4 (Portrait), 16:9 (Landscape), 9:16 (Portrait)

Outputs (3)

NameTypeDescription
spritesheetIMAGE
alphaMASK
metadataSTRING