Nodes/braintacles-nodes/Empty Latent Image from Aspect-Ratio
ComfyUI Node

Empty Latent Image from Aspect-Ratio

One latent, any aspect ratio — without touching a calculator

By braintacles·Created 3 years ago·Updated 2 years ago· 2
Empty Latent Image from Aspect-Ratio
    • samples
    • width
    • height
    • aspect ratio
    short_side1024
    orientation
    aspect_ratio1:1
    batch_size1
    seed0

    Every sampler needs an empty latent, and for most workflows the core Empty Latent Image node is fine - type 1024×1024, done. It's only when you start batch-working cinematic ratios that the fun begins. Want a 2.35:1 or 21:9 frame? The core node makes you do the multiplication yourself, then hope the result lands on a multiple of 8. This node from the braintacles pack does that arithmetic for you: type the ratio, pick an orientation, and you get a correctly-sized latent plus the width, height and ratio back as numbers you can reuse.

    How it works

    The latent is a block of zeros in VAE latent space - 4 channels at 1/8 resolution, exactly what the core node produces. short_side is what everything hangs off: the node takes your "W:H" string, divides, and scales the other dimension so the shorter edge lands on short_side. The orientation decides which side is the short one. square makes both equal, landscape pins the height to short_side and widens, portrait pins the width and grows tall. random rolls the orientation from the seed.

    The inputs and outputs that matter

    Four inputs do the real work:

    • short_side (default 1024, 64–4096 in steps of 8) - your resolution budget; the smaller edge of the image.
    • orientation - square, landscape, portrait, or random.
    • aspect_ratio - the "W:H" string, like 16:9 or 2.35:1.
    • batch_size - multiplies the latent for batched gens. seed only matters when orientation is random.

    Outputs: samples (LATENT) feeds the latent_image input on a KSampler. The sneaky-useful part is the other three - width and height (INT) and aspect ratio (FLOAT) - because you can wire them into anything that wants a resolution, like image-size conditioning or a metadata node, instead of hardcoding numbers.

    Where people get burned

    Two quirks, both real, both in the code.

    The latent is floored to multiples of 8, but width and height report the ideal value. 2.35:1 at short_side 1024 gives a 2400×1024 latent while the width output says 2406 - off by up to 7px. The sampler doesn't care, but if you feed that width output into something that checks it against the actual latent, you'll see a mismatch.

    The other one is portrait. The math wants the ratio typed with the longer number first: type 3:2 in portrait mode to actually get a tall image - 2:3 comes out short and wide, backwards from what the notation implies. Also note 1:1 always forces a square even if you pick landscape. Run one test frame before you trust the orientation in a batch.

    Install

    cd ComfyUI/custom_nodes
    git clone https://github.com/braintacles/braintacles-comfyui-nodes
    

    or search braintacles-nodes in ComfyUI Manager and restart. It's a single-file pack with no Python dependencies and no model downloads - it only calls ComfyUI's own APIs, which is also why it still works years after the last update.

    Is it essential? No - the core node plus a calculator gets you there. But if you live in 2.39:1 anamorphic or flip between portrait and landscape layouts, this is the one braintacles node you'll actually reach for.

    Categorybraintacles/latent

    Inputs (5)

    NameTypeDefaultDescription
    short_sideINT102464–4096
    orientationCOMBO4 options: square, landscape, portrait, random
    aspect_ratioSTRING1:1
    batch_sizeINT11–64
    seedINT00–18446744073709550000

    Outputs (4)

    NameTypeDescription
    samplesLATENT
    widthINT
    heightINT
    aspect ratioFLOAT