Empty Latent Image from Aspect-Ratio
One latent, any aspect ratio — without touching a calculator
- samples
- width
- height
- aspect ratio
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, like16:9or2.35:1.batch_size- multiplies the latent for batched gens.seedonly matters when orientation israndom.
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.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| short_side | INT | 102464–4096 | — |
| orientation | COMBO | 4 options: square, landscape, portrait, random | |
| aspect_ratio | STRING | 1:1 | — |
| batch_size | INT | 11–64 | — |
| seed | INT | 00–18446744073709550000 | — |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| samples | LATENT | — |
| width | INT | — |
| height | INT | — |
| aspect ratio | FLOAT | — |