getImageRetio☀
What aspect ratio is that image, exactly? This node does the math
- image
- ratio
- width_ratio
- height_ratio
The name is a typo - it's "Retio", not "Ratio" - and honestly that tells you the level of polish you're getting here: a small, single-purpose node that does one math job and does it fine. Feed it an image, and it tells you the simplified aspect ratio, both as a human string like 3:4 and as two separate numbers.
Why would you want that in a graph? Because aspect ratio is one of those values that other nodes keep asking you for. Gemini image generation nodes want an aspect ratio enum. Upscalers and resizers sometimes want to preserve the source ratio. Dataset tooling wants to know what shape your images are. Rather than reading dimensions off a Properties window and typing the ratio by hand, you can wire this node's output into whatever wants it and let the value travel with the workflow.
How it works
It takes the first image from whatever you feed it (a batch or a list is fine - it grabs the first frame), reads the width and height, computes width / height, and simplifies it with fractions.Fraction.limit_denominator(100). That's the part that turns 1.7777... into 16:9 instead of 1777:1000.
The three outputs:
- ratio - the string, e.g.
3:4or16:9. - width_ratio and height_ratio - the same ratio as two INTs, for wiring into nodes that want numbers.
Where it falls short
- It's approximate by design.
limit_denominator(100)means a slightly-off source ratio snaps to the nearest clean fraction. If your image is 1000×1001, you'll get something like1:1, not the "true" ratio. For most purposes that's the desired behavior; for pixel-exact work it isn't. - No output for bad input. Non-image or empty input gives you
invalid imageand zeros rather than a crash - readable, if not informative. - First image only. It's not a per-frame node.
Install
Part of the DashuaiTools pack:
cd ComfyUI/custom_nodes
git clone https://github.com/Hasasasa/ComfyUI_DashuaiTools
then restart ComfyUI, or use ComfyUI Manager ("DashuaiTools"). No dependencies beyond what ComfyUI ships - it's torch and fractions, both standard.
It's a helper, not a headline feature, but if you've ever hand-typed an aspect ratio into a node and gotten it wrong, you'll see the appeal.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| ratio | STRING | — |
| width_ratio | INT | — |
| height_ratio | INT | — |