Nodes/oshtz Nodes/Easy Aspect Ratio
ComfyUI Node

Easy Aspect Ratio

Stop Typing 1344×768 — Easy Aspect Ratio Picks the Size For You

By oshtz·Created 2 years ago·Updated 2 months ago· 6
Easy Aspect Ratio
    • ratio
    • width
    • height
    aspect_ratio

    Easy Aspect Ratio is a one-trick node, but it's the trick you'll stop being annoyed by. You pick "9:16" from a dropdown and it hands you the ratio as text plus a width and height that actually play nice with a diffusion model. No more squinting at a latent-size mismatch error because you typed 764 instead of 768.

    It's part of the oshtz Nodes pack, and it exists because ComfyUI's stock Empty Latent Image node makes you type dimensions by hand every single time. If you're switching between portrait, landscape, and square shots across a workflow, that's a lot of raw numbers floating around. This node turns a ratio into three usable outputs so you only ever think in "16:9", not "1344×768".

    How it works

    The mechanism is embarrassingly simple - and that's the point. Behind the dropdown is a hardcoded table of the classic SDXL "bucket" resolutions: 1:1 maps to 1024×1024, 2:3 to 832×1216, 16:9 to 1344×768, and so on through 25 presets including ultrawide 21:9 and the portrait mirror of everything. These are the same sizes SDXL was trained at, which is why they're the safe choices for that family of models.

    The one thing the node does after the lookup is clamp everything to a multiple of 8:

    width = (width // 8) * 8
    height = (height // 8) * 8
    

    That's a real constraint, not paranoia - most latent models want dimensions divisible by 8, and feeding them anything else is how you get dimension errors or silently weird crops. Some presets are already 8-aligned, some aren't (7:4 gives 1344×768), so the guard matters.

    The inputs and outputs that matter

    There's exactly one input, which is the whole appeal:

    • aspect_ratio - the dropdown. 25 presets, from 1:1 and 2:3 through 3:1, 4:1, 16:10 and the rest.

    And three outputs, all of which wire somewhere obvious:

    • ratio (STRING) - the "9:16" label itself. Handy if you want the ratio in a saved filename or passed into a text-based node.
    • width (INT) and height (INT) - plug these straight into Empty Latent Image's width/height, a KSampler's latent, or a conditioning resize node.

    A typical hookup: dropdown → Empty Latent Image, with the same width/height going into any upscale or controlnet node that needs to match the latent. Since it all comes from one source, the numbers can't disagree.

    Installing it

    This is one of five nodes in the oshtz Nodes pack, so installing the pack gives you all of them. Easiest route is ComfyUI Manager - search for "oshtz" or "oshtz Nodes". Or do it by hand:

    cd ComfyUI/custom_nodes
    git clone https://github.com/oshtz/ComfyUI-oshtz-nodes.git
    cd ComfyUI-oshtz-nodes
    pip install -r requirements.txt
    

    Then restart ComfyUI. Dependencies are light - just requests, pydantic, Pillow, and numpy, all of which you likely already have. No model downloads, no API keys.

    Honest caveats

    This node encodes SDXL bucket sizes, which are the safe defaults for SDXL-line checkpoints. If you're running something with a different sweet spot, the values still work because they're 8-aligned and reasonable - you'll just be leaving a little quality on the table versus the model's native resolutions. And if you're feeding it into a fixed-pixel workflow (say, an API node that only accepts 1024×1024), you'll still want to check the size before you hit Generate. But for day-to-day SDXL work, "pick a ratio, forget the math" is exactly what you wanted.

    Categoryoshtz Nodes

    Inputs (1)

    NameTypeDefaultDescription
    aspect_ratioCOMBO25 options: 1:1, 2:3, 3:4, 5:8, 9:16, 9:19, +19

    Outputs (3)

    NameTypeDescription
    ratioSTRING
    widthINT
    heightINT