Resolution Scale
Scale a resolution with a ceiling, not a surprise
- Width
- Height
Somewhere between "the image is 1024×1024" and "I want it 1.5× bigger" lives a bunch of bookkeeping: multiply both sides, keep the aspect ratio, don't blow past a memory ceiling, and land on a number the model will accept. NNResolutionScale exists for exactly that - it scales an existing resolution up or down while keeping it aligned and capped.
What it is
NNResolutionScale is a pure calculator node (no pixels involved) that takes a width and height, multiplies both by scale_by, applies a max_resolution cap, and rounds both to a divisible_by multiple. It outputs two integers, Width and Height, ready to feed an Empty Latent Image, an upscale step, or any size-dependent node. The README's description covers it: "Upscale or downscale resolutions, maintains aspect ratio, prevents exceeding maximum resolution, rounds dimensions for model compatibility."
How it works
The logic is short and predictable:
new = old × scale_byon both dimensions.- If the longest side exceeds
max_resolution, scale everything down proportionally so the longest side lands exactly at the cap. - Round both dimensions down to a multiple of
divisible_by.
Aspect ratio is preserved by construction - both axes get the same multiplier, and the cap step applies one uniform factor. The result prints in the node's UI so you can see it without tracing wires.
That max_resolution cap is the quiet hero here. Scale 1024×1024 by 3 and you'd get 3072×3072, which is a lot of VRAM for a latent; with max_resolution at 2048, the node instead returns ~2048×2048 and never lets you accidentally overshoot. This is the guardrail that makes the node safe to wire into a workflow and forget.
The inputs
width/height- the resolution you're scaling, 64–8192, defaults 1024 each.scale_by- 0.01–16, default 1.0. Below 1.0 downscales.divisible_by- 2–256, default 2. Alignment multiple (8 or 16 for latent work).max_resolution- 64–8192, default 2048. The ceiling on the longest side.
Outputs: Width (INT), Height (INT).
When to reach for it
The classic spot is a hi-res pass: you have the base resolution from NNImageResolution (or from a sampler), you want a 1.5× upscale for the second pass, and you want to guarantee you don't blow your VRAM budget - so you chain NNImageResolution → NNResolutionScale with a cap, then feed the result into the latent upscale. It's also handy for normalizing mixed resolutions before feeding a batch node, and for parameterized workflows where "scale factor" should be one widget that everything downstream respects.
Installing
Part of bandifiu/ComfyUI-NN-custom-nodes:
cd ComfyUI/custom_nodes
git clone https://github.com/bandifiu/ComfyUI-NN-custom-nodes
Restart ComfyUI (or Manager → "NN-custom-nodes"). Deps: torch, numpy, pillow - no models. GPL-3.0, newer V3 backend API.
Two small behaviors to keep straight. First, rounding is down and happens after the cap, so the output can sit a hair under your cap rather than exactly on it - harmless, but don't expect the longest side to always equal max_resolution exactly. Second, unlike NNImageResolution, this node doesn't reshape to an aspect ratio - it scales whatever you hand it and only cares about the cap. Feed it mismatched ratios and it preserves them, which is usually what you want from a "scale" node.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| width | INT | 102464–8192 | — |
| height | INT | 102464–8192 | — |
| scale_by | FLOAT | 1.000.01–16 | — |
| divisible_by | INT | 22–256 | — |
| max_resolution | INT | 204864–8192 | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| Width | INT | — |
| Height | INT | — |