Force Detect Pixelate Scale
Find the pixel grid and snap to it — without touching the colors
- image
- down_img
- detected_scale
If you generate pixel art with an AI model, the image usually comes back at a resolution that's not an exact multiple of its real pixel grid. A sprite that's genuinely 32x32 might render as 112x112, or 301x301, with the blocks smeared across non-aligned boundaries. This node finds the real scale of that grid and downsamples the image to it using nearest-neighbor - one pixel block per source block, with the original colors left completely alone. It's the "detect the scale" half of the Unfake pipeline, exposed standalone for when you want the grid found but you'll handle the palette yourself.
How it works
This is where the pack's actual code matters, because the logic is more careful than the name suggests. It runs a three-stage detection pipeline from utils.py. First it tries a runs-based detector: it counts where color changes happen along rows and columns, builds a signal of boundary positions, and looks for a periodic spacing - the spacing is the pixel size. If that comes back as "no grid found" and the image's longest side is bigger than the bypass_resolution threshold, it falls back to a brute-force test: for each candidate scale from 2 to 16 it downsamples to that grid, resamples back up with nearest-neighbor, and measures the reconstruction error. The scale with the lowest error wins.
Then it takes the original image and divides its dimensions by the detected scale, resizing with Image.Resampling.NEAREST. So you get a downsampled image where every output pixel corresponds to one "real" pixel of the sprite, and the detected_scale output (a FLOAT) tells you what that scale was.
Inputs and outputs
- image - the pixel art to analyze.
- bypass_resolution (default 256, range 8–4096) - this is a shortcut, not a target resolution. If the image's longest side is at or below this value, the node skips detection entirely and passes the image through unchanged with
detected_scale = 1. The idea: a small image is probably already at sprite scale, so why spend the cycles. Where this trips people up: feed it a 200px image and you'll getdetected_scale = 1even if it's clearly chunky pixel art. Raise the threshold if you're analyzing small-but-pixelated sources.
Outputs: down_img (the grid-aligned IMAGE) and detected_scale (FLOAT). The scale value can be wired into an integer/factor scale node or used as a sanity check - you are looking at the real grid if it comes back as a sane number like 4 or 8, and suspicious if it's 1 on something that's clearly pixel art.
Installing it
ComfyUI Manager → Install Custom Nodes → search ComfyUI_UnfakePy_Warpper, or:
cd ComfyUI/custom_nodes
git clone https://github.com/AhBumm/ComfyUI_UnfakePy_Warpper
Then restart. The pack's requirements.txt is just unfake==1.0.7 and nest_asyncio; unfake drags in opencv, Pillow, and NumPy, and needs Python 3.10+. No models to download, runs on CPU.
The honest caveats
This node detects and downsamples, but it does not quantize colors or clean up blur - it's the grid step, not the whole cleanup. Feed it a soft-edged fake-pixel render and you'll get a hard-edged-but-still-muddy image, because the color mixing between blocks is still there. That's by design; the sibling Unfake Pixelate Tools node runs the full pipeline (detect + quantize + clean) in one shot. Use this one when you want the grid math separate from the art decisions, or when you want to verify what scale the image is actually working at before you commit to a palette.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| bypass_resolution | INT | 2568–4096 | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| down_img | IMAGE | — |
| detected_scale | FLOAT | — |