Nodes/Recommended Resolution Calculator/Recommended Resolution Calculator
ComfyUI Node

Recommended Resolution Calculator

Stop typing random resolutions into SDXL — let this node do the math

By marhensa·Created 3 years ago·Updated about a year ago· 91
Recommended Resolution Calculator
    • recomm width
    • recomm height
    • upscale factor
    • reverse upscale for 4x
    • reverse upscale for 2x
    desiredXSIZE1024
    desiredYSIZE1024

    The Recommended Resolution Calculator is a two-input math node that answers the one question every SDXL workflow starts with: what size should I actually generate at? You tell it the final resolution you want on disk, and it hands back the SDXL-trained resolution to render at plus the exact upscale factor to get from there to your target. No models, no API calls, no VRAM - it's a lookup table with a calculator bolted on, and it runs in the time it takes to blink.

    Why does that matter? SDXL wasn't trained on arbitrary resolutions. The SDXL paper (page 17) lists 41 discrete aspect ratios - 1024x1024, 1152x896, 1216x832, 1344x768, and so on through every rotation down to 512x2048. Generate at something in that family and the model behaves; generate at, say, 1920x1080 directly and you invite the classic SDXL party tricks: stretched bodies, doubled limbs, repeated patterns. The standard play is generate at a trained ratio, then upscale - which is exactly what this node automates.

    How it works

    Under the hood it's simpler than the workflow it saves you from. The node computes your desired aspect ratio (desiredXSIZE / desiredYSIZE), walks all 41 accepted ratios from the paper, and picks the one with the smallest difference. That ratio's pixel dimensions become the recomm width / recomm height outputs. Then it figures out the upscale factor as the larger of desiredX / acceptedX and desiredY / acceptedY - taking the max so neither axis ends up undersized; you'll crop a hair off one edge.

    The reverse upscale for 4x and reverse upscale for 2x outputs are the clever bit. Upscale models like 2x-UltraSharp or 4x-UltraSharp only work at their native multiple. If the recommended start is 1024x1024 and you want 1536x1536, the scaling factor is 1.5 - but you can't ask a 2x model for 1.5x. So you upscale 2x to 2048, then scale down by 1.5 / 2 = 0.75 to land exactly on target. That's the reverse factor: the ImageScaleBy value to apply after a fixed 2x or 4x upscale.

    The inputs and outputs that matter

    Only two inputs, and they're self-explanatory: desiredXSIZE and desiredYSIZE, the final resolution you want. Both are ints (default 1024, range 0–8192, step 2) - the README's own framing is "your TARGET FINAL RESOLUTION."

    The five outputs wire into a familiar pattern:

    • recomm width / recomm height → straight into EmptyLatentImage (and the matching SetLatentSize / conditioning sizes).
    • upscale factor → into LatentUpscaleBy or ImageScaleBy if you're doing a straight pixel upscale.
    • reverse upscale for 4x / 2x → the ImageScaleBy factor to apply after a 4x or 2x upscale model so the result lands at your exact target.

    The included example workflow (sdxl-recommended-res-calc_upscale-case.json) shows exactly this: calc → EmptyLatentImage → sampler → UpscaleModelLoader → ImageScaleBy using the reverse factor.

    Installing it

    Easiest path is ComfyUI Manager - search Recommended Resolution Calculator and install. Or clone it manually:

    cd ComfyUI/custom_nodes
    git clone https://github.com/marhensa/sdxl-recommended-res-calc.git
    

    Restart ComfyUI and it shows up under utils. There are no dependencies to worry about - the pack ships no requirements.txt; it's pure Python stdlib, so nothing heavy drags in with it. (The repo also includes standalone .bat / .sh scripts that do the same math outside ComfyUI, if you ever want it as a quick CLI.)

    Where people get burned

    • It's SDXL-only. That hardcoded ratio table is straight from the SDXL paper. SD 1.5 lives at 512x512, and Flux doesn't care about discrete ratios at all (just keep it divisible by 64) - feeding this node's numbers to either will give you nonsense. Fine for SDXL, Pony, and Illustrious; wrong for everything else.
    • It picks nearest, not exact. Your 16:9 target maps to 7:4 (1344x768) because that's the closest trained ratio - the community-standard answer too. But "nearest" means you'll always crop or slightly overshoot one axis. That's normal; budget a small crop.
    • The upscale factor is a ratio, not a destination. It tells you how much to scale, so you still need a real upscaler node downstream - this node doesn't upscale anything itself.
    • Zero is a footgun. The inputs allow 0, and a 0 height makes the division blow up. Keep both above 128 and you'll never see the error.

    It's a tiny tool that does one job honestly, from a pack author (marhensa) who knows their way around the ecosystem. If you keep fighting SDXL's anatomy at odd resolutions, this is the 30-second fix - and once the numbers are wired, you'll stop thinking about resolution entirely.

    Categoryutils

    Inputs (2)

    NameTypeDefaultDescription
    desiredXSIZEINT10240–8192
    desiredYSIZEINT10240–8192

    Outputs (5)

    NameTypeDescription
    recomm widthINT
    recomm heightINT
    upscale factorFLOAT
    reverse upscale for 4xFLOAT
    reverse upscale for 2xFLOAT