ComfyUI Node

Palettize

Snap a frame batch onto a fixed color swatch

By Mister-Link·Created 9 months ago·Updated 23 days ago· 0
Palettize
  • image
  • alpha_opt
  • frames
swatchGame Default
num_colors256
swatch_path

Generate pixel art or sprite assets with AI and you run into a specific, annoying problem: every generation picks its own slightly-different set of colors, so nothing you produce actually matches the existing palette of the game or project you're building for. Palettize is the fix - it forces your output onto a fixed, chosen color swatch instead of whatever colors the model happened to land on.

What it's for

This sits in the pack's game-art corner alongside Pixelate, Sprite Scale Calculator, and Spritesheet Builder. Where Pixelate does color quantization from scratch (pick however many colors best represent the image), Palettize maps onto a palette you specify - the difference between "reduce this to a nice-looking set of colors" and "reduce this to these exact colors." That's the node you reach for once you already have an established palette (a game's existing sprite sheet, a brand's color set) and need new assets to match it exactly rather than approximately.

The output socket is named frames, not image - a hint that this is built with animated sequences in mind. Run a whole batch through it and every frame gets mapped onto the same palette consistently, which matters for animation: quantizing frames independently tends to make colors flicker slightly between them, and a shared, fixed palette avoids that entirely.

The inputs and outputs that matter

  • image - your source image or frame batch.
  • swatch - where the target palette comes from: Game Default (a built-in preset, no extra setup), External Swatch (loads from a path you provide), or From Input.
  • num_colors - palette size: 256, 128, 64, or 48. Fewer colors gives you a more obviously retro, limited look; more stays closer to full-color while still being locked to a fixed set.
  • swatch_path (optional) - used with External Swatch; point it at your swatch source.
  • alpha_opt (optional MASK) - hook this up for transparent PNGs so transparent regions don't get pulled into the palette matching.

Output: frames - the palette-mapped result, same shape as your input.

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 model downloads needed for this node specifically.

Common issues & troubleshooting

Colors bleeding through on transparent PNGs. alpha_opt is optional, which means it's easy to forget. Skip it on an RGBA source and fully transparent pixels still get run through the palette match like everything else - connect your mask whenever alpha actually matters to the output.

External Swatch with no path set. swatch_path defaults to empty, and it only does anything when swatch is set to External Swatch. If your palette isn't showing up as expected, check that the path field is actually filled in and that you've selected the matching swatch mode - leaving it on Game Default while typing a path does nothing.

Expecting the swatch to auto-adjust to num_colors. The four num_colors choices interact most predictably with the built-in Game Default presets, which are provided at those specific sizes. If you're feeding your own external swatch, its actual color count is what you get regardless of the num_colors selection - the field isn't a universal downsampler for any swatch you throw at it.

Categorycolor

Inputs (5)

NameTypeDefaultDescription
imageIMAGE
swatchCOMBOGame Default3 options: Game Default, External Swatch, From Input
num_colorsCOMBO2564 options: 256, 128, 64, 48
swatch_pathoptSTRING
alpha_optoptMASK

Outputs (1)

NameTypeDescription
framesIMAGE