Nodes/ControlAltAI Nodes/Get Image Size Ratio
ComfyUI Node

Get Image Size Ratio

Read width, height and aspect ratio off any image

By gseth·Created 2 years ago·Updated about a year ago· 209
Get Image Size Ratio
  • image
  • width
  • height
  • ratio

Small node, obvious job: hand it an image and it tells you the width, the height, and the aspect ratio. Every node pack has some flavor of "get image size" - what makes this one worth knowing is the third output. It doesn't just give you numbers, it gives you a ratio string, and that string is built to plug straight into the pack's Flux Resolution Calculator.

You'd reach for it any time your workflow needs to react to whatever image happens to be flowing through - an upscale that should match the source shape, a second pass that needs the original dimensions, a batch where the inputs aren't all the same size.

How it works

There's exactly one input, image, and three outputs: width (INT), height (INT), and ratio (STRING). Width and height are the pixel dimensions. The ratio is the simplified aspect (something like 16:9), formatted as text.

The intended trick is chaining it into the Flux Resolution Calculator. As the author lays it out: on the resolution node, right-click, Convert Widget to Input, convert custom_aspect_ratio to an input, then wire this node's ratio output into it. Now your Flux resolution follows the shape of an incoming image automatically, and the calculator handles snapping it to a clean, Flux-friendly megapixel size. That's a genuinely nice pattern for "regenerate at Flux's preferred resolution but keep the original framing."

The inputs and outputs that matter

There are only four things here, so:

  • image - whatever image you want measured.
  • width / height - feed these into a latent, a crop, an upscale-by-side calculation, wherever you need the raw numbers.
  • ratio - the string. Its whole reason to exist is the Flux Resolution Calculator hookup above.

That's the entire node. No settings, no toggles.

How to install it

ComfyUI Manager → search ControlAltAI Nodes → install → restart. Or clone it and restart:

cd ComfyUI/custom_nodes
git clone https://github.com/gseth/ControlAltAI-Nodes

No models, no dependencies - it's a couple of tensor-shape reads.

Common issues

Almost nothing goes wrong with a node this simple. The one thing worth knowing: the ratio output is a formatted string, so treat it as text - it's meant for the resolution calculator's custom_aspect_ratio field, not for math nodes that expect a float. If you need to do arithmetic, use the width and height INT outputs instead. And if you're reading the size of a batch, remember these outputs describe the tensor's dimensions, which are shared across the batch - they won't hand you per-image sizes for a mixed batch.

CategoryControlAltAI Nodes/Image

Inputs (1)

NameTypeDefaultDescription
imageIMAGE

Outputs (3)

NameTypeDescription
widthINT
heightINT
ratioSTRING