AspectToResolution
Let AspectToResolution do the math
- width
- height
AspectToResolution is the node version of that calculator tab you keep open next to ComfyUI. You pick an aspect ratio, tell it how many megapixels you can afford, and it hands you the exact width and height to type into an Empty Latent Image - already snapped to the right multiple so you don't get the "latent size not divisible" wall of warnings. It's a pure utility, one input table in and two integers out, and it quietly removes the most annoying bit of mental math in every text-to-image workflow.
Why this exists: latent sizes have divisibility requirements that vary by model, and nobody remembers them. Most SD checkpoints want multiples of 8, SDXL is comfortable at 16, and video models like Wan or LTX-Video often want 16 or 64. The classic failure is setting 1216×832, thinking you're being clever, and getting a silently-resampled or error-throwing latent. This node just refuses to produce that kind of number.
How it works
The math is boring in the good way. It takes your aspect ratio as a width:height pair (so 16:9 is (16, 9)), computes total pixels = megapixels × 1024 × 1024, then scales both sides to hit that pixel count and rounds each down to the nearest multiple. Two things worth knowing:
- A "megapixel" here is 1,048,576 pixels, not the marketing round million. Set 1 MP on 1:1 and you get exactly 1024×1024. That's deliberate - it's the resolution the whole ecosystem thinks in.
- Because of the rounding-to-multiple step, the output is near your target megapixels, not exact. 0.1 MP on 9:21 doesn't land precisely at 0.1; it lands at the nearest valid step. Don't panic when the number looks slightly off - that's the point.
The three inputs that matter
aspect_ratio- a dropdown with 11 presets, from 1:1 Square up through 9:21 Very Tall Portrait and 21:9 Ultrawide. Everything you'd reasonably want is there; there's no free-text field, so if you need something exotic you'll be approximating with the nearest preset.megapixels- float from 0.1 to 16, default 1.0. This is your VRAM budget in disguise. 1 MP for a 1024-ish SDXL workflow; push toward 2 if you're going for a hires pass.multiple- int, default 8, range 8 to 128. This is the divisibility of your model. 8 is the safe default for most checkpoints; set it to 16 or 64 for video latent models. It's the input beginners tune last and the one that actually fixes the "invalid latent" errors.
Outputs
width (INT) and height (INT) - that's it. Wire them into an Empty Latent Image (or an Empty SD3/FLUX latent, whatever your model uses) and you're done. Because they're plain integers you can also feed them into a KSampler's width/height directly in an upscale pass, or chain this node into a resolution-dependent setup.
Installing it
It ships in Link Comfy Nodes, so install the pack, not a single file:
- Easiest: ComfyUI Manager → search "Link Comfy Nodes" → Install → restart.
- Or manually:
cd ComfyUI/custom_nodes
git clone https://github.com/Mister-Link/link-comfy-nodes
cd link-comfy-nodes
pip install -r requirements.txt
# restart ComfyUI
The honest caveat: this pack installs a lot of machinery for a single calculator node. Its requirements.txt drags in torch, transformers, opencv-python, scikit-learn, numba and a CLIP build from GitHub - most of which exist because the pack's other nodes do matting, pixel art, and video work. ComfyUI has no per-node isolation, so installing it puts all of that into your shared Python environment (see the ecosystem doc's dependency-hell section for why that bites). If you only want AspectToResolution, you could in principle copy the single file, but that breaks on every update.
The gotchas
The pack's own README is one sentence: "AI slop nodes for my own purposes, use at your own risk (I change how nodes behave without warning)." That's the author's framing, and it's honest - this is a personal utility pack, not a maintained product, so pin the version or expect behavior changes on update.
Also note it's a calculator: there's no image input, so it can't read the aspect ratio of a reference image for you. If that's what you need, look at an image-size/bbox node instead. For everything else - pick ratio, set megapixels, keep multiple at 8 unless your model says otherwise - this is the one you'll reach for every single time.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| aspect_ratio | COMBO | 11 options: 1:1 (Square), 2:3 (Portrait), 3:2 (Landscape), 4:5 (Portrait Standard), 5:4 (Landscape Standard), 9:16 (Portrait Widescreen), +5 | |
| megapixels | FLOAT | 1.00.1–16 | — |
| multiple | INT | 88–128 | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| width | INT | — |
| height | INT | — |