Aspect Ratio
9' without a calculator
- ratio
- ratio_string
If you've ever stared at a resolution and asked "wait, is that 16:9 or 3:2?", this is the node that answers. It takes a width and a height and gives you two things: the decimal ratio (1.777...) and the simplified fraction as a string ("16:9"). It's the rare utility node where the string output is the interesting one - most math in ComfyUI hands you numbers, but this one hands you the human-readable answer too.
It's from the Utilitools pack, and it sits in the same category as the pack's Image Dimensions node, which makes for a natural pair: Image Dimensions reads an actual image and gives you width/height; this node takes those numbers and tells you what shape that is. Wire width and height from Image Dimensions straight into Aspect Ratio and you've got an automatic "what am I looking at" readout for any loaded image.
The inputs
Only two, both required, both plain INTs:
- width - 1 to 8192, default 512
- height - 1 to 8192, default 512
Nothing else. No image input, no options - you feed it numbers, it does the math.
What it outputs
- ratio - a FLOAT, computed as
width / height. 1920 / 1080 gives you 1.7778. - ratio_string - a STRING, the ratio simplified to its lowest terms using the greatest common divisor:
"16:9","3:2","1:1", and so on.
The fraction is the party trick. A 1200×800 image isn't obviously 3:2 by eye, but the node reduces it via GCD to exactly that. Useful for logging, for prompts that reference aspect ratios, or for building aspect-aware workflows that branch on shape.
Where it bites
Order matters, and it's always width-then-height. A portrait image - 1080×1920 - gives 0.5625 and "9:16", not "16:9". If you're feeding from Image Dimensions that's automatic and correct, but if you type the numbers in by hand, swap width and height and your "16:9" silently becomes "9:16". Also note it just reports the ratio of the numbers you give it - it doesn't validate that the resolution is generation-friendly or a multiple of 8. Garbage in, an accurate ratio for garbage out. And because it returns a float, ratio is most useful for comparisons and branching; for anything human-facing, the string is the output you'll actually display.
Installing it
Standard Utilitools install:
cd ComfyUI/custom_nodes
git clone https://github.com/aesethtics/ComfyUI-Utilitools
or search "Utilitools" in ComfyUI Manager and restart. It's under Utilitools → Image. No dependencies, no model files, no requirements.txt - this pack is pure Python. It's a small pack with no real community footprint, but for "what aspect ratio is this resolution" it's the cleanest one-box answer around.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| width | INT | 5121–8192 | — |
| height | INT | 5121–8192 | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| ratio | FLOAT | — |
| ratio_string | STRING | — |