Nodes/AAA Metadata System/Aspect Ratio for 2step Latent Sample
ComfyUI Node

Aspect Ratio for 2step Latent Sample

Latent dimensions without doing the math

By EricRollei·Created 11 months ago·Updated 10 months ago· 14
Aspect Ratio for 2step Latent Sample
  • image
  • width
  • height
  • ratio_string
  • ratio_float
◄base_resolution512►
◄aspect_ratio1:1 Square►

There's a class of fast-sampling workflows - turbo models, two-step latent sampling, that family - where you care a lot about getting the latent dimensions right and very little about doing long division. Aspect Ratio for 2step Latent Sample exists for exactly that: pick a base resolution and an aspect ratio, and it hands you width and height that are divisible by 16, ready to feed into your latent sampler.

It's a small, honest utility node from the AAA Metadata System pack. The description on the tin says it all: "Calculate width and height for 2-step latent sampling based on aspect ratio and base resolution. All outputs are divisible by 16." If you've ever run a latent sampler with a 1080×1000 resolution and gotten a tiling artifact or a "latent shape mismatch" error, you know why the divisibility matters - latent spaces want clean multiples, and 16 is the safe floor.

How it works

You choose a base_resolution (the shorter side, 256–1024 in 64-step increments) and an aspect_ratio from a list of presets - portrait, square, landscape, plus the ultrawide and A-paper ratios. The node computes the other dimension, then rounds both down to multiples of 16. The ratio presets are stored as simple width:height pairs (9:16, 3:2, 16:9, 21:9, and so on), so it's pure arithmetic - no model, no network.

The nice touch: if you connect an image, its actual aspect ratio is used instead of the dropdown, and the dropdown is ignored. That's the workflow for "match this reference image's framing" - drop the reference in, read out the numbers, feed them to your latent node.

Inputs and outputs that matter

  • base_resolution - the shorter-side target. 512 is a sane default for SD-family models; go higher for hires work.
  • aspect_ratio - the framing preset. Ignored when an image is connected.
  • image (optional) - a reference image whose ratio overrides the dropdown.

Outputs: width and height (INTs - wire straight into your latent/sampler sizing inputs), ratio_string (like "16:9", handy for display), and ratio_float (the numeric ratio, if some node wants the raw number).

Installing it

Part of AAA Metadata System by Eric Hiss (GitHub: EricRollei). Via ComfyUI Manager (search "AAA Metadata System") or:

cd ComfyUI/custom_nodes
git clone https://github.com/EricRollei/AAA_Metadata_System.git
cd AAA_Metadata_System
pip install -r requirements.txt

Restart ComfyUI. No dependencies beyond the pack's core install.

Common issues

Rounding is the thing to watch. The node rounds to multiples of 16, so a 16:9 at base 512 gives you 912×512, not 911.11×512 - that's correct behavior, but if you're pixel-perfecting a final image, remember the actual ratio is the rounded one, not the ideal one. Some samplers are happier with multiples of 64; 16 is the guarantee here, so for ultra-strict workflows you may still round up yourself. And if you connect an image and the numbers look wrong, check the image's orientation - a rotated source will happily hand back a landscape size for a portrait frame. That's on the source, not the node.

Categoryimage/preprocessing

Inputs (3)

NameTypeDefaultDescription
base_resolutionCOMBO512Base resolution for the shorter side (256-1024 in 64-step increments)
aspect_ratioCOMBO1:1 SquareSelect aspect ratio. Ignored if image is connected.
imageoptIMAGEOptional input image. If provided, its aspect ratio will be used instead of the dropdown selection.

Outputs (4)

NameTypeDescription
widthINT—
heightINT—
ratio_stringSTRING—
ratio_floatFLOAT—