Nodes/comfyui-OreX/📐 Ratio (OreX)
ComfyUI Node

📐 Ratio (OreX)

Stop doing latent math in your head

By orex2121·Created about a year ago·Updated 3 days ago· 34
📐 Ratio (OreX)
    • width
    • height
    • empty_latent_image
    • empty_sd3_flux1_latent
    • empty_flux2_latent
    ratio1:1 ◻
    Megapixel1.00
    Megapixel = 1024^2true
    Multiplicity16
    custom_width1024
    custom_height1024

    Every ComfyUI user has sat there trying to work out what 16:9 at 1 megapixel actually is, then discovered the answer isn't a round number, and then had to nudge it to a multiple of 8 so the sampler doesn't complain. Ratio (OreX) does that thinking for you and throws in the three latents you'd otherwise have to source from separate Empty Latent nodes. It's a small utility, but it's the kind that quietly lives in every workflow you build after discovering it.

    How it works

    You pick an aspect ratio and a target megapixel count; the node computes width and height so that width × height lands at your target, then rounds both to a multiple of Multiplicity (16 by default - the sweet spot for most models). The math is unremarkable and correct: it solves for height = sqrt(pixels / ratio) and derives width from that, then snaps to your step.

    What's less obvious is the "Megapixel = 1024²" toggle. On (the default), 1 megapixel means 1024 × 1024 - which is why 1:1 at 1 MP gives exactly 1024×1024, the native sweet spot of SDXL/Flux-style models. Off, it means 1,000,000 pixels flat. Keep it on unless you have a reason; model makers almost always mean 1024² when they say "1MP."

    The outputs that matter

    This is where the node earns its keep. It returns five things:

    • width and height - the computed integers, for feeding image sizes elsewhere.
    • empty_latent_image - a standard 4-channel latent (SD 1.5 / SDXL, 8× downscale), directly usable in a KSampler.
    • empty_sd3_flux1_latent - 16-channel latent for SD3 / FLUX.1.
    • empty_flux2_latent - 128-channel latent for FLUX.2 (16× downscale).

    So one node replaces three Empty Latent nodes and a calculator. Pick your model family, grab the matching latent output, and you're done. The Custom ratio entry uses custom_width / custom_height as the ratio instead of the preset list - handy for that odd 7:5 panel you keep using.

    Inputs worth knowing

    • ratio - 16 aspect presets from square (1:1) through ultrawide (32:9) and tall (9:32), or Custom.
    • Megapixel - the target area, 0.1 to 50.
    • Multiplicity - the rounding step. Leave at 16 unless you're chasing a specific pixel count; 8 works but is rarely needed.

    Install

    Standard pack install - ComfyUI Manager (search "comfyui-OreX") or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/orex2121/comfyui-OreX
    

    Then restart. Zero extra dependencies and no models - this one is pure torch math.

    The honest caveat

    The latent outputs are all baked into one node, which means every model-family workflow you make with it carries two extra latent outputs you'll never use. Ignore them - or don't, because it's still faster than building three Empty Latent nodes from memory. Where people do get tripped up is feeding the wrong latent into the wrong sampler: a 16-channel Flux latent into an SDXL sampler is an immediate error. Match the output to your checkpoint and this node just quietly works.

    CategoryOreX

    Inputs (6)

    NameTypeDefaultDescription
    ratioCOMBO1:1 ◻16 options: 1:1 ◻, 5:4 ▭, 4:3 ▭, 3:2 ▭, 16:9 ▭, 2:1 ▭, +10
    MegapixelFLOAT1.000.1–50
    Megapixel = 1024^2BOOLEANtrue
    MultiplicityINT168–256
    custom_widthINT102464–16384
    custom_heightINT102464–16384

    Outputs (5)

    NameTypeDescription
    widthINT
    heightINT
    empty_latent_imageLATENT
    empty_sd3_flux1_latentLATENT
    empty_flux2_latentLATENT