ControlAltAI: Get Image Size Ratio
Read the numbers off any image, then stop guessing aspect ratios
- image
- width
- height
- ratio
Feed it an image, get back its width, its height, and its aspect ratio as a string like 7:9. Three outputs, one input, nothing else.
That sounds like a node you'd write in five minutes and forget, but the ratio string is the interesting part: it's reduced by the greatest common divisor, so it talks in the same language as a resolution calculator. Which is exactly what this node was built to talk to.
How it works
_, height, width, _ = image.shape
gcd = greatest_common_divisor(width, height)
ratio = f"{width // gcd}:{height // gcd}"
ComfyUI images are (batch, height, width, channels), so the shape unpack is the whole "read the pixels" story - no decode, no copy, no GPU work. 1024×1024 becomes 1:1. 896×1152 becomes 7:9, not 896x1152. 832×1216 becomes 13:19. If you were expecting a decimal like 1.666, you won't get one, and that's deliberate.
The one caveat: it reads the first image of the batch and reports that as the size for the whole tensor. In practice batches are uniform, so this almost never matters - but if you've concatenated differently-sized images, the numbers are for image zero only.
Inputs and outputs
image- requiredIMAGE.width-INT.height-INT.ratio-STRING, reduced form,W:H.
What you'd wire it into
The intended pairing is in the same node family: ControlAltAI: Megapixel Calculator, which picks output dimensions from an aspect ratio. The step you have to do yourself is convert the calculator's custom_aspect_ratio widget to an input (right-click → Convert widget to input), then plug ratio into it. Now the resolution of your generation matches whatever reference image you dropped in, without you typing numbers - restore a photo, upscale a game asset, or match a client's crop, and the canvas follows automatically.
The width and height integers are useful on their own too: feed them to a resize node to keep proportion, or to a hires-fix second pass, or to a latent-size node when you're doing an img2img pass at the source resolution. It's also the easiest way to discover what an image actually is when you've inherited a workflow from someone else and want to know why it looks soft. (It's 1152 wide. That's why.)
Worth knowing why a resolution calculator even exists in a graph: aspect-ratio bookkeeping is genuinely annoying, and Flux-style models care about megapixels more than they care about "SDXL sizes." The community's habitual answer, whenever someone posts a "I hate looking up aspect ratios" tool, is to point at ControlAltAI's resolution node - this pack's Calculator is the same family, so the ratio string is a drop-in for that workflow.
Installing it
Ships in ussoewwin/ComfyUI-NunchakuFluxLoraStacker, a pack that also carries a Nunchaku FLUX LoRA stacker, Florence-2 captioning nodes, a TensorRT CCSR upscaler and the rest of the ControlAltAI set (a Python 3.13 fork of gseth/ControlAltAI-Nodes; the hswq_ class prefix keeps it from colliding with the original). ComfyUI Manager: search ComfyUI-NunchakuFluxLoraStacker. Manual:
cd ComfyUI/custom_nodes
git clone https://github.com/ussoewwin/ComfyUI-NunchakuFluxLoraStacker.git
pip install -r requirements.txt
Restart afterwards. No models to download and no GPU work for this node, but install the full requirements file regardless: the pack imports its CCSR dependencies (pytorch-lightning, taming-transformers, omegaconf, einops, open-clip-torch) at load time, and one missing package means none of the pack's nodes show up. nunchaku is guarded, so a machine that can't run Nunchaku still gets this.
If something's off
The ratio looks weird. Check the reduction before you assume a bug: 13:19 is 832×1216, and 21:9-looking crops often reduce to primes that don't resemble any preset. If the calculator won't accept it, that's a preset-coverage problem, not a this-node problem - use the raw width/height outputs instead.
The number is stale. The node re-runs when the graph re-runs; if you swapped the image upstream and the value didn't move, you're looking at a cached execution, not a wrong reading.
It's not in the menu. The pack failed to import - check the console for the pip traceback. And remember workflows referencing the original GetImageSizeRatio class type won't resolve to this node; the prefixed name is a different class.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| width | INT | — |
| height | INT | — |
| ratio | STRING | — |