Detect Aspect Ratio
The node that just tells you what shape your image is
- image
- aspect_ratio_str
You've got a reference image. You like its framing. You want your generated output - or the video you're about to shoot at it - to have the same framing, not a squashed approximation of it. That's the entire job of AspectRatioDetector, and it does that job in about twenty lines of Python with no models, no API calls and no network access at all.
It ships inside phibbyrizz/ComfyUI-Prompt-Studio, a reference-image-to-prompt pack that sends your image to multimodal models through OpenRouter and gets back a still prompt or a MiniMax H3-style video script. The detector was folded in for prompt-studio-suite v3.3, so you no longer need the old standalone aspect-ratio node. Read the README's framing carefully, because it's honest: the ratio is a readout. It does not resize, does not pick a generation resolution, does not inject anything into the AI prompt, and does not talk to your downstream generator.
How it actually works
The source is short enough to read in a code review. ComfyUI's IMAGE type is a tensor shaped [batch, height, width, channels]. The node divides width by height, picks whichever entry in a hardcoded table of nine ratios sits closest to that number (minimum absolute difference), and returns that entry's label.
The nine, in no particular order beyond the author's: 16:9 (Landscape), 9:16 (Portrait / Story), 1:1 (Square), 4:3 (Standard Photo), 3:4 (Portrait Photo), 2:3 (Classic Portrait), 3:2 (Classic Landscape), 21:9 (Cinematic Ultrawide), 9:21 (Ultrawide Portrait).
Because it's nearest-match against a fixed list, it rounds. Drop a 4:5 Instagram crop in and you get 3:4 (Portrait Photo) - 0.8 is 0.05 from 0.75 and 0.13 from 0.667. Drop in 5:4, you get 4:3. A 1.85:1 DCI flat frame comes back as 16:9. Not a bug - it reports the closest standard ratio, which is usually what you wanted.
The sockets, which are two
image(IMAGE, required) - anything that emits pixels. Wire it fromLoad Imageto read your reference's shape, or fromVAE Decodeto check the shape you actually generated.aspect_ratio_str(STRING, the only output) - the label, complete with its parenthetical. There's no bare-numbers mode, so if you want2:3on its own for a filename you'll be trimming that string somewhere else.
That last point trips people up: a STRING output sitting unplugged shows you nothing. The shipped workflow wires it straight into Show Text|pysssss (from ComfyUI-Custom-Scripts) - the standard move for any string you want to see on canvas. Do the same and the reference shape is right there in front of you. Unlike the rest of the pack, this node needs none of those companion packs and no OpenRouter key; it's pure arithmetic over a tensor shape, so it works even when your API half is throwing errors.
Installing it
It comes with the pack, so install the pack. In ComfyUI Manager, search Prompt Studio Suite (publisher phibbyrizz) and restart. The README hedges that one with "once published to the Comfy Registry", so if your Manager search comes up dry, clone it:
cd ComfyUI/custom_nodes
git clone https://github.com/phibbyrizz/ComfyUI-Prompt-Studio
Then restart ComfyUI and search the node list for Detect Aspect Ratio, or right-click → Add Node → Prompt Studio.
Only the full workflow needs the other packs (ComfyUI-Custom-Scripts for Show Text, ComfyUI-KJNodes for StringConstant, rgthree-comfy, comfyui-openrouter). The detector itself pulls in nothing - dependencies = [] in the pack's pyproject.toml, and the node file has no imports at all. Nothing to download, no requirements.txt to fight.
Where it goes wrong
The duplicate-node trap. If you ever installed the old standalone ComfyUI_AspectRatioDetector folder, delete it before installing this. Two packs registering the same class name is a classic way to get a node that loads, red-lights, or silently resolves to the wrong implementation - and you'll waste an evening on it.
"I see no ratio." The output is a string and nothing renders it unless something consumes it. Add Show Text.
It reports the pixels you gave it, not the pixels you asked for. Feed it Load Image for the reference's real dimensions, or VAE Decode for what you actually output.
It's one string for the whole batch. A Comfy IMAGE batch is a single stacked tensor, so all the images in it share dimensions and you get one answer.
The honest caveat: knowing the ratio is half the job. On SDXL and SD 1.5 you're still constrained to the trained buckets - 1024x1024, 1152x896, 1216x832, 1344x768, 1536x640 - and off-ratio generation is how you get stretched bodies. Most 2026 models take any size in a 1–2 MP band and degrade softly, which is why a plain readout is enough now. Want a node that computes the resolution, snaps to a 64px grid and enforces a model's buckets? That's a different tool (ResolutionMaster is the one the subreddit upvoted). This one reads, and the author is upfront about that.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| aspect_ratio_str | STRING | — |