π§ Get Aspect Ratio
Snap your canvas to a sensible aspect ratio instead of eyeballing it
- aspect_w
- aspect_h
Every model has a handful of aspect ratios it actually likes. You can keep feeding it 913Γ1017 and it'll cope, or you can snap to a clean 4:3 / 16:9 / 1:1 and stop fighting the latent space for no reason. That snap is the entire job of this node: give it a width and height, it hands back the closest enabled ratio as a clean aspect_w/aspect_h pair.
It's pure math - no image, no model, nothing to download - and it's one half of a two-node chain that generates at the "right" size. Pair it with the pack's Image Size Calculator and you get a pipeline that turns "whatever size my source is" into "a canonical ratio at a resolution I chose."
How it works
Feed it width and height. It works out your input's aspect (handling portrait vs landscape so a tall image snaps to a portrait ratio, not a sideways landscape one), then compares against the enabled ratios in the list and returns the nearest match. The ten booleans - 1:1, 4:3, 3:2, 5:4, 16:9, 16:10, 21:9, 2:1, 1.85:1, 2.39:1 - are a filter, not a picker. Disable cinematic ratios and a 2.35:1 source gets rounded to whatever's left instead.
Outputs are aspect_w and aspect_h as ints (so 16:9 comes out as 16, 9, not "16:9" as a string). That's deliberate: they're meant to plug straight into another node's numeric inputs.
When you'd reach for it
- Source image at a weird size, and you want to regenerate at a ratio that matches the source's intent.
- You want every batch output at one of a small set of platform ratios (Instagram square, YouTube 16:9) regardless of what you throw at it.
- You're tired of hand-typing 896Γ1152. One source-size input and the chain resolves it.
Install
ComfyUI Manager, search "ComfyUI-SuperNodes", or:
cd ComfyUI/custom_nodes
git clone https://github.com/sonnybox/ComfyUI-SuperNodes
Restart, done. This is part of the π§ SuperNodes pack, which is built on ComfyUI's newer extension API - update ComfyUI if the nodes don't show up. No model files, and the pack's only real Python dependency is matplotlib (and that's only for the Sigmas Graph node, not this one).
Gotchas
- It snaps to nearest. A 0.99:1 input returns 1:1, which is usually what you want - but don't expect hysteresis if your source hovers between ratios.
- Disable every toggle and it falls back to 1:1 rather than erroring, which is friendly but easy to trip over while you're cleaning up a workflow.
- It returns a ratio, not a resolution. Wire the result into Image Size Calculator or Empty Latent Image to get actual pixel dimensions.
The whole thing is about thirty lines of ratio math. That's fine. You'll miss it the first time you try to build a batch of consistent-ratio generations from heterogeneous source sizes without it.
Inputs (12)
| Name | Type | Default | Description |
|---|---|---|---|
| width | INT | 10241β65536 | β |
| height | INT | 10241β65536 | β |
| 1:1 | BOOLEAN | true | β |
| 4:3 | BOOLEAN | true | β |
| 3:2 | BOOLEAN | true | β |
| 5:4 | BOOLEAN | true | β |
| 16:9 | BOOLEAN | true | β |
| 16:10 | BOOLEAN | true | β |
| 21:9 | BOOLEAN | true | β |
| 2:1 | BOOLEAN | true | β |
| 1.85:1 | BOOLEAN | true | β |
| 2.39:1 | BOOLEAN | true | β |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| aspect_w | INT | β |
| aspect_h | INT | β |