Nodes/ComfyUI-Info-Prompt-Toolkit/Aspect Ratio to Size
ComfyUI Node

Aspect Ratio to Size

Sane resolutions without the division rounding headache

By kinorax·Created 5 months ago·Updated about a month ago· 2
Aspect Ratio to Size
    • width x height
    • width
    • height
    width_ratio10
    height_ratio16
    min_unit32
    width864
    height1376
    actual_ratio

    Every diffusion model has a resolution it was trained on, and SDXL's 1024×1024 family runs noticeably better when your dimensions stay on sensible multiples - 8, 16, 32, or 64, depending on the architecture and the downscaling math that follows. The problem is that "10:16 aspect, please" rarely lands on a nice number: 10/16 of 1024 is 640, sure, but 9:16 of 1344 gives you 756, which is not divisible by 64, which is not divisible by 8's cousin 4... and suddenly you're hand-editing a dimension that fights your model. Aspect Ratio to Size is the pack's node for doing that arithmetic once, correctly, and snapping the result to a clean step.

    It's the kind of utility that feels trivial until you've spent ten minutes in a calculator deciding whether your portrait should be 864×1376 or 880×1408. The answer, per the node: 864×1376 is the default, snapped to a 32-unit grid.

    How it works

    You give it a ratio and a base size, and it derives the missing side. The key fields:

    • width_ratio (default 10) and height_ratio (default 16) - your target aspect, e.g. 10:16 for portrait.
    • width (default 864) and height (default 1376) - you edit one of these as the anchor; the node derives the other from the ratio.
    • min_unit (default 32) - the snap step; options are 8 / 16 / 32 / 64.
    • actual_ratio - a read-only display of what ratio you actually ended up with after snapping.

    The node resolves the size, snaps both dimensions up to a multiple of min_unit, and recomputes the real ratio. So when you drag width to 1000, height doesn't come out as the awkward exact match - it lands on the nearest valid step that preserves your intent. The actual_ratio field is the author's way of showing you the truth about what you got, and it's worth a glance before you hit run.

    The outputs give you the result three ways: width x height (a single combined IPT-Size value for nodes that take a size bundle), plus separate width and height INTs for the more common case of feeding KSampler-style resolution inputs or an empty-latent node.

    Which min_unit should you use?

    The honest rule: match your model's preference. SDXL-class models are happy with 64-step multiples; many others work fine on 8 or 16. Snapping to a larger unit costs you a little precision but buys you compatibility; snapping to a smaller one can produce resolutions the model's VAE handles awkwardly. The 32 default is a sensible middle ground - it's what the author ships, and for the pack's SDXL-oriented workflows it's rarely wrong. If you're on a model with a hard 64 requirement, change it once and leave it.

    The honest caveat

    This node only does resolution math - it doesn't create a latent, set up an empty latent, or touch the sampler. You still wire width and height into whatever actually builds the latent. And "9:16" in your head is width_ratio=9, height_ratio=16, not 16:9; flip them by accident and you get a landscape when you wanted a portrait. The actual_ratio display is the thing that catches that before you waste a run.

    Installing

    Part of kinorax/comfyui-info-prompt-toolkit:

    cd ComfyUI/custom_nodes
    git clone https://github.com/kinorax/comfyui-info-prompt-toolkit.git
    cd comfyui-info-prompt-toolkit
    pip install -r requirements.txt
    

    or install "Info-Prompt-Toolkit" via ComfyUI Manager, then restart. No model files - it's pure arithmetic. The pack also ships a Split Width/Height node to unpack a combined size back into its parts, and the (Trim Margin) variant of this node if you need to sample oversized and crop afterward.

    CategoryInfo-Prompt-Toolkit/ImageInfo

    Inputs (6)

    NameTypeDefaultDescription
    width_ratioINT101–4096Aspect ratio width
    height_ratioINT161–4096Aspect ratio height
    min_unitCOMBO32Minimum size step
    widthINT8648–16384Width
    heightINT13768–16384Height
    actual_ratioSTRINGDisplay only

    Outputs (3)

    NameTypeDescription
    width x heightIPT-Size
    widthINT
    heightINT