ComfyUI Node

Quick Ratio

Stop doing aspect-ratio math in your head

By Dragon7108·Created 3 months ago·Updated 3 months ago· 1
Quick Ratio
    • width
    • height
    preset1:1
    base_resolution1024
    divisible_by8
    custom_width_ratio1
    custom_height_ratio1

    Every image model has a native resolution, and every one of those gets weird if you feed it a random rectangle. SDXL wants 1024-ish, SD 1.5 wants 512, and models trained on specific aspect ratios will happily give you stretched limbs and tiling when you wander too far off them. Figuring out that 21:9 at 1024 long-edge means 440 short-edge, and then snapping it to a multiple of 8 so the VAE doesn't choke, is exactly the kind of arithmetic nobody wants to do mid-workflow. Quick Ratio is a five-second fix for that: pick a preset or type your ratio, give it a base resolution, and it hands you clean width and height integers ready to wire into an Empty Latent Image.

    What it actually does

    Under the hood it's a small lookup table and two lines of math - no model files, no dependencies, nothing to download. The base_resolution always sets the longer side: for landscape presets (16:9, 4:3, 3:2, 21:9) it becomes the width, and the shorter side is computed from the ratio. Portrait presets are the mirror image, so the same 1024 gives you 576×1024 for 9:16 instead of 1024×576. Then the computed side is snapped to your divisible_by value, because models want dimensions that line up with their VAE - 8 covers most SDXL models, 16 is the Flux crowd's usual ask, and some architectures want 64.

    There are two details worth knowing before you reach for it. First, snapping means the output isn't pixel-perfect on the ratio - at 1024 and divisible_by 8, 21:9 lands on 440 rather than the exact 438.9. That's a feature, not a bug; a few pixels off is invisible, a dimension that isn't divisible will throw errors. Second, it's rigid about which side is the long one. You cannot use this node to produce a 512-wide portrait or a 576-wide landscape by setting base_resolution - the base is always the long edge.

    The inputs that matter

    You only really touch three of the five:

    • preset - dropdown with 12 common ratios (1:1, 16:9, 9:16, 4:3, 21:9, and portrait/landscape variants) plus custom.
    • base_resolution - the long-edge target. 1024 for SDXL, 512 for SD 1.5, whatever your checkpoint's native resolution wants.
    • divisible_by - default 8; bump to 16 for Flux, higher for models that demand it.

    If you pick custom, two optional INTs appear - custom_width_ratio and custom_height_ratio - so 17:10 is just 17 and 10. The outputs are exactly two INTs, width and height, which plug into Empty Latent Image's width/height slots or any other resolution widget. There's also a live preview badge on the node that recomputes the dimensions as you drag the sliders, which makes it feel almost like a calculator.

    Installing it

    In ComfyUI Manager: Install via Git URLhttps://github.com/Dragon7108/ComfyUI-QuickRatio, or drop into a terminal:

    cd ComfyUI/custom_nodes
    git clone https://github.com/Dragon7108/ComfyUI-QuickRatio
    

    Restart ComfyUI. There's nothing else to install - no requirements, no weights, no keys. This is one of the rare custom nodes where the README's "no extra dependencies" is actually true (the shipped pyproject.toml declares an empty dependency list).

    Where people trip

    The usual failure isn't the node - it's feeding it a resolution your model was never trained near, then blaming the calculator. Generate at native res and upscale afterward; that's what hires fix, ESRGAN, and ControlNet Tile are for. If you're on Flux and getting weird results, don't forget to raise divisible_by to 16 or 64. And if your ratio won't snap to what you expect, check whether you meant a custom ratio instead of a preset - the presets are fixed, but the custom pair covers anything they don't.

    Categoryutilities

    Inputs (5)

    NameTypeDefaultDescription
    presetCOMBO1:113 options: 1:1, 11:17, 16:9, 9:16, 4:3, 3:4, +7
    base_resolutionINT102464–8192
    divisible_byINT81–256
    custom_width_ratiooptINT11–100
    custom_height_ratiooptINT11–100

    Outputs (2)

    NameTypeDescription
    widthINT
    heightINT