Nodes/ComfyUi-MpiNodes/Mpi Get Aspect Ratio
ComfyUI Node

Mpi Get Aspect Ratio

9?' — the node that stops you doing mental math

By MadPonyInteractive·Created 11 months ago·Updated 5 days ago· 3
Mpi Get Aspect Ratio
    • string
    • pack
    width1024
    height1024

    Every image generation workflow ends up asking the same dumb question: what aspect ratio am I actually working at? Mpi Get Aspect Ratio exists so you never have to divide width by height in your head again. You feed it a width and a height, and it outputs ratio - a STRING naming the closest standard ratio. The answer comes back as 1:1, 4:3, 3:2, 16:9, 9:16, 2:3, or 3:4.

    The mechanism is simple and honest about being simple: divide width by height, then snap to whichever of the seven standard ratios is numerically closest. So 1920×1080 gives 16:9; 1080×1920 gives 9:16; 1024×1024 gives 1:1; 1200×800 gives 3:2. It's a nearest-match, not a rounding scheme, which means slightly-off dimensions still land on the ratio they're meant to be. It does not give you a numeric ratio like 1.777 - you get the named standard, which is exactly what a human (or a routing node) wants.

    Inputs: width and height, both INT with defaults of 1024 and a range of 64 to 4096. Output: ratio (STRING). There's nothing else - no widgets, no modes. If you need the numeric ratio, divide the width and height yourself in a math node; this one's job is naming.

    Where this earns its place is as a routing signal. The output string can feed a switch that picks between portrait and landscape pipelines - load the 9:16 model path when ratio is 9:16, the 16:9 path when it's 16:9. It's also genuinely useful in prompt building and metadata: a prompt that wants to mention "portrait orientation," or a filename that should carry the aspect. Pair it with an image-loading node's width/height outputs (most loaders expose them) and you get "read the aspect off whatever image came in, then route accordingly" - which is the portrait/landscape auto-switching trick a lot of advanced workflows are built on.

    The honest limitations: seven standard ratios is a short menu, and genuinely oddball crops (say, 5:4 or ultra-wide 21:9) snap to the nearest standard rather than getting their own label. If you need the exact fraction or a custom set, this isn't the node. And it works on numbers, not on images directly - you wire it the width and height, which most of the pack's image nodes already output. It's a small node with a small job, and that's the point: one wire in for the answer you'd otherwise compute by hand every single time you change resolution.

    Install is pack-standard: ComfyUI Manager → search ComfyUi-MpiNodes → install, or clone it:

    cd ComfyUI/custom_nodes
    git clone https://github.com/MadPonyInteractive/ComfyUi-MpiNodes
    

    Restart, and it's under MpiNodes/ImgOps. No requirements file, no model downloads - pure Python on top of ComfyUI, the same pack behind the Cubric Vision app.

    CategoryMpiNodes/ImgOps

    Inputs (2)

    NameTypeDefaultDescription
    widthINT102464–4096
    heightINT102464–4096

    Outputs (2)

    NameTypeDescription
    stringSTRING
    packMPI_PACK