Nodes/NN-custom-nodes/Resolution Scale
ComfyUI Node

Resolution Scale

Scale a resolution with a ceiling, not a surprise

By bandifiu·Created about a month ago·Updated about a month ago· 0
Resolution Scale
    • Width
    • Height
    width1024
    height1024
    scale_by1.00
    divisible_by2
    max_resolution2048

    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:

    1. new = old × scale_by on both dimensions.
    2. If the longest side exceeds max_resolution, scale everything down proportionally so the longest side lands exactly at the cap.
    3. 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 NNImageResolutionNNResolutionScale 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.

    CategoryNN

    Inputs (5)

    NameTypeDefaultDescription
    widthINT102464–8192
    heightINT102464–8192
    scale_byFLOAT1.000.01–16
    divisible_byINT22–256
    max_resolutionINT204864–8192

    Outputs (2)

    NameTypeDescription
    WidthINT
    HeightINT