Shima Flatten Colors
Crush your render down to a flat, cel-shaded palette
- images
- IMAGE
A diffusion render comes out with thousands of smooth gradients. Sometimes you don't want smooth - you want the crisp, posterized look of cel animation, a sprite palette, or a print. Shima.FlattenColors takes an image and quantizes it down to a fixed number of colours, replacing the gradient mush with flat bands of tone. Feed it a render and you get back something that looks drawn, not generated.
The mechanism is a classic image-processing move, and it's worth knowing because it tells you what the node can't do. The image is converted to palette mode with Pillow's ADAPTIVE palette - Pillow picks the N most representative colours from the actual image and maps every pixel to the nearest one. That's palette reduction, the same trick GIFs have used for thirty years, not "AI style transfer." No model runs, no VRAM is touched, the output is a deterministic remap. (For the broader "everything that's not a model" pixel-tool context, see the post-processing doc - this family is where the KB keeps these.)
The inputs are exactly two:
- images (IMAGE) - the input, and yes, it accepts a batch; each frame is flattened independently.
- number_of_colors (INT, 1–4000, default 5) - how many colours to keep. 5 is a bold, almost screen-print look. 8–16 gives that banded cel-shade vibe most people are after. Crank it to hundreds and you're basically just quantizing lossily - at that point you're closer to a compression test than a style.
Output: an IMAGE, same dimensions as the input.
A couple of honest observations. First, ADAPTIVE palette selection is statistical, so two similar renders with the same colour count can pick slightly different palettes - if you need a consistent palette across a whole batch (say, matching frames in a video loop), this node isn't the tool; you'd want a fixed-palette quantizer. Second, because it works in Pillow on the CPU, it's fast and memory-light but not vectorized - for a huge batch it'll take a moment. And keep the colour count in proportion to what the image actually contains: pushing a photo with 2000 colours down to 3 is a bold move that mostly produces noise silhouettes.
Where it earns its place: the flat-color graphic look for album art and posters, a cheap "clean lineart" pass before upscaling, or converting a photoreal render into something that reads as an illustration. It's one of those nodes you won't use on every run, but when you want the look, nothing else gets you there in one click.
Install the pack via ComfyUI Manager (search "Shima") or
cd ComfyUI/custom_nodes
git clone https://github.com/KDB-USJP/shima_wf
then restart. No models, no extra dependencies - Pillow ships with ComfyUI.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| images | IMAGE | — | |
| number_of_colorsopt | INT | 51–4000 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |