Nodes/comfy_Pond_Nodes/🐳像素校正
ComfyUI Node

🐳像素校正

Un-squish the rectangles in your pixel art

By Pondowner857·Created about a year ago·Updated 21 days ago· 45
🐳像素校正
  • 图像
  • 图像
  • 像素宽度
  • 像素高度
检测模式
像素宽度1
像素高度2
输出模式
对齐方式

Pixel Correction (🐳像素校正) fixes a very specific, very annoying artifact: pixel art whose pixels are rectangles instead of squares. It happens all the time. You upscale an NES-style sprite and the pixels come out 4 wide × 5 tall. You export from a canvas that had a non-square pixel ratio. You grab a screenshot of a retro game that was stretched. Suddenly every "pixel" is a little brick, and the whole image has that subtly wrong, smeared texture. This node detects the pixel grid and re-shapes it so every cell is 1:1.

The mechanism is honest and simple. It estimates the size of a single pixel in the image - either automatically (检测模式 set to 自动检测, which measures the repeating grid) or by hand (手动设置, where you type 像素宽度 and 像素高度, defaults 1×2). Then it resamples the image with NEAREST interpolation, which is the crucial detail: nearest-neighbor keeps hard pixel edges crisp instead of blurring them into gradients, which is exactly what you want when the whole point is a clean pixel grid. (The KB's post-processing doc makes the same point in the other direction - pixel art workflows live and die on crisp edges and limited palettes, and a careless Lanczos pass is how you destroy both.)

Then you pick how to fix the ratio with 输出模式:

  • 拉伸图像 (stretch) - squashes or stretches the whole canvas so pixels become square
  • 添加边距 (add margins) - keeps the canvas, pads to square the ratio
  • 裁剪图像 (crop) - trims to the square interior

对齐方式 (alignment - center, or any corner) matters mainly for the margin/crop modes: it decides where the image sits in the resulting canvas.

Outputs and where it fits

Three outputs: the corrected 图像 (IMAGE), plus 像素宽度 and 像素高度 (INT) - the detected or set grid size, which is handy if you want to chain this into a pixel-art upscaler that needs to know the native pixel dimensions (RealESRGAN's pixel-art variant, or a plain nearest-neighbor integer upscale). Feed it from the pack's own pixelization node (🐳像素化) or any pixel-art source.

The honest take: this is a niche utility. If you don't work on pixel art, you will never touch it - there are far more general "fix the aspect ratio" nodes around. But if you do generate sprites, it's the difference between "close enough" and "clean grid," and it's a millisecond deterministic op that costs you nothing to drop into a pipeline. One trap: auto-detection guesses the grid from repeating structure, and it can misread a noisy image. If the corrected output looks worse, switch to 手动设置 and type the actual pixel size - you can usually read it off the source by zooming in.

Install

Part of Pond Nodes:

cd ComfyUI/custom_nodes
git clone https://github.com/Pondowner857/comfy_Pond_Nodes
cd comfy_Pond_Nodes
pip install -r requirements.txt

Restart after (or Manager → "comfy_Pond_Nodes"). Pure PIL/numpy/torch under the hood, so no extra models or optional dependencies. The README's HiDream-Sampler console-spam conflict note applies to the pack as a whole.

Category🐳Pond/图像

Inputs (6)

NameTypeDefaultDescription
图像IMAGE
检测模式COMBO2 options: 自动检测, 手动设置
像素宽度INT11–64
像素高度INT21–64
输出模式COMBO3 options: 拉伸图像, 添加边距, 裁剪图像
对齐方式COMBO5 options: 居中, 左上, 右上, 左下, 右下

Outputs (3)

NameTypeDescription
图像IMAGE
像素宽度INT
像素高度INT