Nodes/ComfyUI-SuperNodes/🐧 Image Size Calculator
ComfyUI Node

🐧 Image Size Calculator

Compute exact generation dimensions for any aspect ratio, every time

By sonnyboxΒ·Created 11 months agoΒ·Updated 4 days agoΒ· 12
🐧 Image Size Calculator
    • width
    • height
    • aspect_w
    • aspect_h
    β—„aspect_w1β–Ί
    β—„aspect_h1β–Ί
    β—„modeβ–Ύβ–Ί
    β—„size1024β–Ί
    β—„megapixels1.00β–Ί
    β—„multiple_of16β–Ί

    "Just set the width and height to a multiple of 64" is the most repeated piece of ComfyUI advice that people still get wrong by hand. This node is the fix: you give it an aspect ratio and a target size, it returns width and height already rounded to a multiple you choose. No mental arithmetic, no accidentally generating 1021Γ—579 because you fat-fingered it.

    It's part of the 🐧 SuperNodes pack by SuperCC, and in a normal workflow it's the second half of the aspect-ratio chain: Get Aspect Ratio snaps a source size to a clean ratio, this node turns that ratio into real pixel dimensions, and the ints feed straight into Empty Latent Image.

    How it works

    aspect_w and aspect_h define the ratio (16 and 9 for 16:9, tooltips say so). Then the mode combo decides what your size input means:

    • max_size - the longer side becomes size. So 16:9 with size: 1024 gives you 1024Γ—576.
    • min_size - the shorter side becomes size. Same ratio, size: 1024 gives 1820Γ—1024.
    • megapixels - ignore size, target a total pixel budget via the megapixels float instead. Handy when you want "about a 1MP image" without caring which side is longer.

    Either way, both dimensions are rounded to the nearest multiple_of (default 16, but 64 or 128 are the values you'll actually want for latent friendliness), and the result is clamped so it never comes back smaller than one multiple_of.

    Outputs are width, height, plus a passthrough aspect_w/aspect_h so you can chain several calculators or a display node off one ratio without re-deriving it.

    When you'd reach for it

    • Standardizing output size across a batch of images with different source ratios.
    • Building a workflow where the resolution is computed from a source image, so you never hardcode dimensions.
    • Target-megapixel generation - a lot of newer models (and upscalers like SeedVR2) behave differently depending on total pixel count, and this lets you lock that number.

    Install

    ComfyUI Manager, search "ComfyUI-SuperNodes", or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/sonnybox/ComfyUI-SuperNodes
    

    Restart ComfyUI. No model downloads. The pack's only extra dependency is matplotlib, and that's for the Sigmas Graph node, not this one. One thing to know: this pack uses ComfyUI's newer extension API, so a stale ComfyUI install simply won't load any of it - keep ComfyUI updated.

    Gotchas

    • Rounding to a multiple is exact, but "nearest multiple" can push a target a hair off - a 1024 target on 16:9 with multiple_of: 64 lands on 1024Γ—576 anyway, but 1.85:1 with a small multiple_of can drift. Set multiple_of to 16 only if you truly need the flexibility; 64 keeps latent math clean.
    • size is interpreted differently by mode, and the default mode is max_size. If you switch to megapixels and leave size set, nothing bad happens - size is just ignored. Don't assume a hidden interaction.
    • It computes, it doesn't crop or pad. Feeding the result to a latent and getting letterboxing is a downstream problem, not this node's.

    This is one of those boring utility nodes you stop noticing after a week - which is the whole point. It removes a class of typos, and typos are what you'll spend an hour chasing otherwise.

    CategorySuperNodes/Tools

    Inputs (6)

    NameTypeDefaultDescription
    aspect_wINT11–1024The width ratio of the desired aspect ratio (e.g., 16 for 16:9).
    aspect_hINT11–1024The height ratio of the desired aspect ratio (e.g., 9 for 16:9).
    modeCOMBODetermines if the size applies to max/min dimension, or if target is total megapixels.
    sizeINT10241–32768The target length for the dimension specified by dimension mode.
    megapixelsFLOAT1.000.01–1024The target total megapixels when mode is 'megapixels'.
    multiple_ofINT161–1024The final dimensions will be rounded to the nearest multiple of this value.

    Outputs (4)

    NameTypeDescription
    widthINTThe calculated width.
    heightINTThe calculated height.
    aspect_wINTPassthrough width aspect.
    aspect_hINTPassthrough height aspect.