ComfyUI Node

Krea 2 Pixel Art Refiner

The deterministic pass that makes AI 'pixel art' actually pixel art

By envy-ai·Created 3 days ago·Updated about 18 hours ago· 9
Krea 2 Pixel Art Refiner
  • image
  • IMAGE
width64
height64
colors24
color_reduction_firsttrue
scale_to_originaltrue

Every pixel-art model in the ecosystem has the same defect, and it isn't fixable by prompting: diffusion models work in a continuous latent space, so they produce something that reads as pixel art from across the room and falls apart the second you zoom in. Different sized "pixels", 300+ colours, soft edges, stray noise. The community position on this is old and correct - Astropulse laid it out in 2025 and nothing has changed since: the model gives you the composition, a deterministic post-process gives you the pixels. Grid-detect and integer downscale, then palette quantize, then nearest-neighbour upscale for display.

This node is that middle pipeline, minus the browser tab and the manual fussing. You hand it a Krea 2 render (or anything else) and it hands back a clean logical grid.

What it actually does

Two operations, and the order is up to you via color_reduction_first.

Palette reduction. The node quantizes each image independently to at most colors values. It converts to OKLab, picks a weighted k-means style set of centres (weighted by how often each unique colour appears, then 12 Lloyd iterations), and maps every unique colour to its nearest centre. Doing this in OKLab rather than RGB is why the result doesn't go muddy around skin tones and oranges - perceptual distance, not channel distance.

Grid collapse. It treats the image as width × height cells and picks one colour per cell, by mode: the most frequent 8-bit RGB value in that cell. Ties go to whichever candidate is perceptually closest to the cell's centre pixel in OKLab, and a remaining tie falls back to the first matching pixel in raster order. So the output is deterministic - same input, same pixels, every time. And because it's modal voting rather than averaging, bright details survive the downscale instead of smearing into grey.

With color_reduction_first on (the default), reduction happens first, so cell votes are cast among palette colours and the output is guaranteed palette-clean. Turn it off and you collapse then reduce - you're voting on raw colours and quantizing afterwards. Stay on the default unless you're chasing a specific look.

The inputs that matter

  • width / height - the logical grid, 64×64 by default. This is the number that decides how chunky your sprite is. A 1024×1024 render at width=64 means 16px cells.
  • colors - cap on palette size, default 24. 16 is the sweet spot for period-correct game art; 32 if you want more shading before it stops reading as pixel art.
  • scale_to_original - on (default) expands the grid back to input dimensions with integer replication. That's the version you look at and feed to Create Video. Turn it off to get the true logical resolution - a 64×64 image - which is what you want for a game engine or a pixel-perfect asset.

There's one output, IMAGE. Wire it to Save Image for a still, or Create Video if you're animating.

Installing it

ComfyUI Manager is the easy path: search ComfyUI-Krea2-Pixel-Art-Refiner (the registry display name is "Krea 2 and MiniMax H3 Pixel Art Refiners", publisher envy-ai) and install. Manually:

cd ComfyUI/custom_nodes
git clone https://github.com/envy-ai/ComfyUI-Krea2-Pixel-Art-Refiner.git krea2_pixel_art_refiner

Then restart ComfyUI. You'll find the node under image/krea2.

Good news on the dependency front: this pack is genuinely light. No model downloads, no checkpoints, no API key. The only third-party requirement is opencv-python-headless>=4.8 (declared in pyproject.toml). opencv is only called by the autorefiner sibling, but it's imported at module level, so the whole pack needs it present even if you only ever use this node - a manual git clone installs nothing, so if the nodes fail to import with a cv2 error, pip install opencv-python-headless in the same environment as ComfyUI.

One note: the pack is written against ComfyUI's newer backend node API (from comfy_api.latest import io), so you won't find NODE_CLASS_MAPPINGS in nodes.py. That's "new", not "broken" - but a genuinely old ComfyUI install will fail on import. Update ComfyUI.

Where people get burned

The most common error by a mile is divisibility. The input dimensions must be evenly divisible by width and height, and the node raises a hard error instead of guessing:

Image size 1024x768 must be divisible by logical grid 64x64

Two ways out. Change the grid so the maths works - 1024×768 at 64×48 gives you 16px cells - or switch to MiniMax H3 Pixel Art Refiner, the sibling in this pack, which has an allow_uneven_grid toggle for exactly this case. The Krea 2 node deliberately doesn't: it's the simple, predictable one.

The other one: width and height can't exceed the image. Asking for a 128-wide grid from a 64px-wide image is an error, not a hallucination.

And do the refinement before you upscale for display, never after. Once a smooth filter has blurred the pixel edges, no amount of modal voting recovers the grid.

Categoryimage/krea2

Inputs (6)

NameTypeDefaultDescription
imageIMAGE
widthINT641–16384Number of logical pixels across the refined image.
heightINT641–16384Number of logical pixels down the refined image.
colorsINT242–256Maximum number of colors in each image's palette.
color_reduction_firstBOOLEANtrueReduce the palette before grid collapse. Disable for collapse-then-reduce behavior.
scale_to_originalBOOLEANtrueExpand the logical pixel grid back to the input dimensions.

Outputs (1)

NameTypeDescription
IMAGEIMAGE