Pixel Perfect Resolution
Stop your ControlNet maps from getting rescaled
- original_image
- RESOLUTION (INT)
This one isn't a preprocessor at all - it doesn't touch your image. It's a tiny calculator that spits out a single number: the resolution your preprocessor should run at so its output lines up cleanly with the resolution you're generating at. Plug that number into your Canny/depth/lineart node's resolution input and your control map stops getting silently up- or down-scaled inside the pipeline. It's a small quality-of-life node that quietly removes a class of soft, misaligned ControlNet results people never realize they're getting.
Why it exists
Here's the problem it solves. Say your preprocessor runs at 512 but you generate at 1024×1024. The control map gets stretched from 512 up to 1024 somewhere in the process, and that resampling smears edges and shifts lines a pixel or two off - enough that a Canny outline no longer sits exactly where the model draws. Run the preprocessor too high and you waste time and can introduce noise. "Pixel perfect" (the idea comes from the sd-webui-controlnet world) means computing the one resolution where the preprocessed map matches the generation target with no rescaling, given how your image will be fit into the output frame. The node does that arithmetic for you.
The inputs and the output
Everything here is required, and it's all straightforward:
original_image- the image you're about to preprocess. The node reads its dimensions; it doesn't modify it.image_gen_width/image_gen_height(both default 512) - the resolution you're actually going to generate at. Set these to your real render size - the KSampler/latent dimensions.resize_mode(defaultJust Resize) - how your image gets fit into that target frame, and it must match how the rest of your workflow handles it.Just Resizestretches to fit,Crop and Resizecrops to fill,Resize and Fillletterboxes. Pick the one your pipeline uses so the math is honest.
The single output is RESOLUTION (INT) - one integer. Wire it straight into the resolution input of whatever preprocessor node you're feeding (Canny, Depth Anything, OpenPose, lineart, any of them). That's the entire job.
How you actually wire it
Original image goes into both this node and your preprocessor. This node's INT output goes into the preprocessor's resolution slot instead of you typing 512 by hand. The preprocessor's IMAGE output continues into ControlNet Apply as usual. Set it once and it adapts automatically when you change your generation size - which is the real convenience, since you'd otherwise be re-deriving that number every time you switch between, say, portrait and landscape.
Installing it
It ships in the same pack as every other node here. ComfyUI Manager: search ComfyUI's ControlNet Auxiliary Preprocessors, install, restart. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/Fannovel16/comfyui_controlnet_aux
pip install -r requirements.txt
Restart ComfyUI. No model download - it's pure arithmetic, so it's instant and needs no weights.
Where people get burned
Two honest caveats. First, this is a polish node, not a fix for a broken workflow - if your ControlNet result is badly wrong, the problem is weight, model choice, or a mismatched preprocessor, not resolution rounding. Pixel-perfect resolution buys you sharpness and alignment, not correctness. Second, the resize_mode field only helps if it matches your actual pipeline; setting it to Crop and Resize while your workflow just resizes gives you a number that's precisely wrong. When in doubt, Just Resize matched to a straightforward "scale the image to the latent size" graph is the safe default. It's a nice-to-have, not a must-have - but on high-res and detail-critical work, it earns its slot.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| original_image | IMAGE | — | |
| image_gen_width | INT | 51264–8192 | — |
| image_gen_height | INT | 51264–8192 | — |
| resize_mode | COMBO | Just Resize | 3 options: Just Resize, Crop and Resize, Resize and Fill |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| RESOLUTION (INT) | INT | — |