- 宽
- 高
AspectRatio (宽高比, "aspect ratio") is a dropdown of 30 preset resolutions with their ratios baked in - 704×1408 ∣ 1:2, 1152×896 ∣ 9:7, 1664×928 ∣ 16:9, and friends - and it outputs the width and height as two INTs. Wire those into an Empty Latent Image, a resize node, or anything that wants pixel dimensions, and you never type a resolution again.
It's the kind of node that feels trivial until you've manually typed 1344×768 for the fifth time in one workflow. The presets mirror the standard SDXL/Flux training-resolutions family (all multiples of 64, landscape and portrait both covered, plus square and the two oddball 3:4 and 4:3 crops), which means they're sensible choices for latent sizing without thinking about divisibility. If you're switching between models with different native resolutions, a shared AspectRatio node is a clean way to keep every downstream consumer consistent.
How it works
The dropdown value is a string of the form "1152×896 ∣ 9:7" - pixels, a full-width multiplication sign, a bar, and the ratio. The node splits on the bar and the × and parses the pixel numbers out, returning them as INT width and INT height. The ratio text after the bar is decorative - it's for humans, not for math. The escape hatch: if you set the width and height inputs to non-zero values, the node ignores the dropdown entirely and returns your custom values instead. That's how you keep the node as your single source of truth while still being able to override it in a specific workflow.
Inputs and output
aspect_ratio- the preset dropdown (default1152×896 ∣ 9:7).width/height- set both non-zero to override the preset.- Outputs:
宽(width) and高(height), bothINT.
Install
In yanlang0123/ComfyUI_Lam - Manager search "ComfyUI_Lam", or:
cd ComfyUI/custom_nodes
git clone https://github.com/yanlang0123/ComfyUI_Lam
restart. Pure string parsing, zero dependencies - the README's install.bat requirements list is irrelevant here.
Gotchas
The override logic has a sharp edge: it's both values non-zero. Set width = 512 but leave height = 0 and the node silently falls back to the dropdown preset, because the check is width == 0 and height == 0 → use preset. Setting just one custom dimension doesn't do what you'd hope. Also, all presets are multiples of 64, which is right for latent sizing - but if you're feeding a VAE or an upscaler that prefers other multiples, pick the preset's value and adjust. It's a "make dimension choices legible and consistent" node, and for that job it's genuinely handy.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| aspect_ratio | COMBO | 1152×896 ∣ 9:7 | 30 options: 704×1408 ∣ 1:2, 704×1344 ∣ 11:21, 768×1344 ∣ 4:7, 768×1280 ∣ 3:5, 832×1216 ∣ 13:19, 832×1152 ∣ 13:18, +24 |
| width | INT | 00–99999 | — |
| height | INT | 00–99999 | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| 宽 | INT | — |
| 高 | INT | — |