ImageRatio
Read an image's aspect ratio as a number
- image
- width_ratio_int
- height_ratio_int
- width_ratio_float
- height_ratio_float
You've got an image and you need its aspect ratio as an actual value you can use - not "looks like 16:9," but numbers you can feed into another node or read off the graph. That's the entire job of easy imageRatio. Feed it an image, get its width-to-height ratio out four different ways.
It's one of the small utility nodes in yolain's ComfyUI-Easy-Use pack. Not glamorous. But when you're building a workflow that has to adapt to whatever image someone drops in - matching an output canvas to a source, deciding an upscale target, branching on portrait vs landscape - having the ratio as a live number beats hardcoding one.
How it works
The node measures the image's width and height and reports the ratio between them. Because it's an output node, it also displays the result right on the node, so you can just glance at it while building.
You get the ratio in four flavors, which sounds like overkill until you need the specific one:
- width_ratio_int and height_ratio_int - the simplified integer pair. Think of it as the "16 and 9" of a 1920×1080 image.
- width_ratio_float and height_ratio_float - the ratio as decimals, for math that needs precision rather than a tidy fraction.
The integer outputs are what you want when you're driving something that expects clean whole-number ratios; the float outputs when you're doing arithmetic and don't care about a pretty reduced fraction.
Inputs and outputs
Input: one image. That's it - there's nothing to configure, which is refreshing.
Outputs: the four ratio values above. Wire the int pair into a resolution or ratio selector; wire the floats into a math node if you're computing a target size. Or wire nothing and just use the on-node display to sanity-check what dimensions came in.
Installing it
The node comes with the pack. In ComfyUI Manager, search "ComfyUI Easy Use," install, restart. Manual route: cd ComfyUI/custom_nodes && git clone https://github.com/yolain/ComfyUI-Easy-Use, run install.bat on Windows or pip install -r requirements.txt, restart. If your theme changes on first launch, that's the pack's UI - Settings → Color Palette to switch back.
Common issues
There's very little to break here - no models, no dependencies, one input. The only thing worth flagging is expectation-setting: this node reports a ratio, it doesn't change anything. It won't resize or crop your image. If your goal is to make an image conform to a ratio, you want a scale or crop node; imageRatio just tells you the number so you can decide what to do next.
If the integer ratio looks odd (like a big ugly pair instead of a clean 16:9), that's just the actual pixel dimensions not reducing to a familiar fraction - an image that's 1000×667 isn't exactly 3:2, so the reduced form is whatever it genuinely is. Reach for the float outputs when the tidy fraction isn't cooperating.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| width_ratio_int | INT | — |
| height_ratio_int | INT | — |
| width_ratio_float | FLOAT | — |
| height_ratio_float | FLOAT | — |