Nodes/mc_cascade_res/Aspect ratio universal v3
ComfyUI Node

Aspect ratio universal v3

Let megapixels and ratio do the math

By tester4488·Created 10 months ago·Updated 9 months ago· 0
Aspect ratio universal v3
    • Width
    • Height
    megapixel1.0
    aspect_ratio_width1
    aspect_ratio_height1
    swap_hwfalse
    multiple_of

    You know the drill: you want a 2.31:1 image, your model has a native resolution band, and you're doing the math in your head - or worse, typing a guess into an Empty Latent and hoping it doesn't come out with stretched bodies. Aspect ratio universal v3 (AspectSize3_mc) is a tiny node from the mc_cascade_res pack that does that arithmetic for you: give it a megapixel target and a ratio, and it hands back a usable Width and Height.

    Why this earns its place in a workflow: every diffusion model is trained at a native resolution, and the golden rule across architectures - from SD 1.5 up through Flux and the video models - is to stay in that band or you get doubled anatomy and repeated patterns. The trick is hitting the band at the ratio you actually want without hand-rolling the math. That's this node's whole job, and it does it cleanly.

    How it works

    The mechanism is plain math, straight from the source. It takes your megapixel budget, squares it as (1024 × megapixel)² to get a total pixel count, computes width from sqrt(pixels × aspect_ratio_width / aspect_ratio_height), and divides to get height. Both are then rounded to the nearest step of multiple_of, and if the rounded pair would overshoot your pixel budget, it steps the width down until it fits.

    That last detail is the one that matters in practice: this node rounds to the nearest multiple, not down, so results can land a hair under your target. That's deliberate and it's good - an over-budget latent is what OOMs you mid-generation.

    The inputs that matter

    • megapixel (float, default 1, range 0.1–100) - your total pixel budget. Note that 1 doesn't mean 1,000,000 pixels; it's 1024², about 1.05 MP. So 1 gives you ~1024×1024, which is exactly the SDXL/Flux sweet spot.
    • aspect_ratio_width and aspect_ratio_height (ints, 1–100) - the ratio as two whole numbers. The README's own example: for 2.31:1, type 23 and 10. For 16:9, type 16 and 9.
    • multiple_of (dropdown: 2 / 4 / 8 / 16 / 32 / 64) - the rounding step. 8 or 16 is fine for stills; pick 16 or 32 if you're feeding a video model, which wants coarser multiples.
    • swap_hw (boolean) - flips the pair, i.e. portrait instead of landscape.

    Outputs are Width and Height as integers. Wire them into an Empty Latent (or Empty Latent Image) by right-clicking that node's width/height widgets and converting them to inputs - the standard value-node dance covered in ComfyUI's plumbing docs.

    Install

    It ships in the mc_cascade_res pack, so install once and you get all four of its nodes. Via ComfyUI Manager, search for mc_cascade_res; or manually:

    cd ComfyUI/custom_nodes
    git clone https://github.com/tester4488/mc_cascade_res
    

    Then restart ComfyUI. No model downloads, no Python dependencies - it's pure utility code. One real requirement: the pack is written against ComfyUI's newer V3 extension API (comfy_api.latest), so it needs a recent ComfyUI. If you hit ModuleNotFoundError: No module named 'comfy_api', update ComfyUI before anything else.

    Where people get burned

    • Don't expect exact SDXL trained ratios. This node gives you a resolution near your budget at your ratio, rounded to a multiple - not the specific 1216×832 that SDXL was trained on. For most uses, especially video models that just want "in-band and divisible by 16 or 32," that's exactly right. If you need a pixel-perfect preset, reach for a preset node instead.
    • swap_hw exists because the ratio inputs are order-sensitive. Forget it and your 16:9 silently becomes 9:16.
    • It lives under MC nodi - that's Italian for "MC nodes," and the pack is a small one-person effort by tester4488. Same pack gives you the LTXV resolutions and Wan frames nodes; if you're doing video, they're handy siblings.

    It's a small, quietly useful tool. The math is right, it never overshoots your budget, and it spares you one more head-scratch per workflow.

    CategoryMC nodi

    Inputs (5)

    NameTypeDefaultDescription
    megapixelFLOAT1.00.1–100
    aspect_ratio_widthINT11–100
    aspect_ratio_heightINT11–100
    swap_hwBOOLEANfalse
    multiple_ofCOMBO6 options: 2, 4, 8, 16, 32, 64

    Outputs (2)

    NameTypeDescription
    WidthINT
    HeightINT