Aspect Ratios
Aspect ratios without the mental math — pick a preset, get width and height
- width
- height
Every time you want a 16:9 image at 720 tall you do the same little bit of arithmetic: width = 720 × 16 ÷ 9. This node is that arithmetic, packaged as a dropdown. Pick a ratio, pick landscape or portrait, type a height, and you get the matching width and height out as integers - ready to feed straight into an Empty Latent or whatever size picker your workflow uses.
It's a tiny utility node and that's the whole point. ComfyUI's base distribution leaves this kind of thing to you, which is why the utility/plumbing layer of the ecosystem is enormous - the KB's node-plumbing doc calls out how much of a typical graph is nodes that "touch no pixels at all." Aspect Ratios is squarely in that camp.
The mechanism is one line of math, visible right in the source. You give it a ratio like 16:9, it splits that into 16 and 9, and:
- landscape: width = height × 16 ÷ 9 (so 720 → 1280).
- portrait: the ratio flips - width = height × 9 ÷ 16 (720 → 405).
Your height value passes through untouched, so you always get back a width/height pair that matches the aspect ratio you picked and the orientation you asked for.
The inputs that matter:
- ratios - one of ten presets:
1:1, 2:1, 3:2, 4:3, 5:4, 7:5, 16:9, 16:10, 21:9, 32:9. Default16:9. - direction -
landscapeorportrait. - height - the side you anchor to, 64 to 2048 in steps of 64, default 720.
Outputs are just width and height, both INT.
The KB's concepts doc has the context you actually care about here: SDXL models were trained at a discrete set of aspect ratios (1024², 1152×896, 1216×832, 1344×768, 1536×640 and their rotations), and generating at one of them is what avoids the "stretched body" complaints. This node's presets won't always land on those exact trained buckets - 16:9 at 720 gives 1280×720, which isn't in SDXL's list - but it's the right shape of tool: decide the ratio once, then every downstream size is consistent. Most latent-size nodes round to a workable value anyway.
One caveat worth knowing: the output isn't rounded to a multiple of 64, and some combinations produce odd numbers (5:4 at 720 → 900×720, for instance). If you're driving a latent directly, run the result through whatever rounding your Empty Latent variant does, or just check the values once.
Install: ComfyUI Manager → search ComfyUI-FairLab → Install → restart. Manual:
cd ComfyUI/custom_nodes
git clone https://github.com/yanhuifair/ComfyUI-FairLab.git
cd ComfyUI-FairLab
pip install -r requirements.txt
Search "Aspect Ratios" after restart. No dependencies beyond the pack itself - this node is pure Python math, so it's about as failure-proof as ComfyUI nodes get.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| ratios | COMBO | 16:9 | The aspect ratio to use. |
| direction | COMBO | landscape | The orientation of the image. |
| height | INT | 72064–2048 | The height of the image. |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| width | INT | — |
| height | INT | — |