EBU Get Image Aspect Ratio From Image
Know your image's aspect ratio without eyeballing it
- image
- aspect_ratio
- resolution
- width
- height
Drop an image into a node and get back a clean "16:9" or "3:2" label, plus its exact pixel dimensions. That's the whole job of EBU Get Image Aspect Ratio From Image, and it's one of those boring utility nodes you don't notice until you're building an automated pipeline that has to make decisions about images it didn't create.
It belongs to a small pack called EBU Workflow (burnsbert/ComfyUI-EBU-Workflow), a grab-bag focused on resolution, upscaling math, and file naming. This node is the "smart" version of the pack's simpler EbuGetImageAspectRatio: same idea, but with a configurable tolerance, a delimiter you control, and - the part that actually matters - width and height integers as separate outputs.
How it works
The mechanism is pure math, no model involved. It reads the first image in the tensor (so batch input only inspects frame one), computes ratio = width / height, then finds the closest entry in a hardcoded list of fourteen common ratios: the usual suspects like 1:1, 4:3, 3:2, 16:9, 16:10, 2:1, plus their portrait twins (9:16, 2:3, 4:5, and so on).
If the closest match is within your tolerance (a float from 0 to 1, default 0.08), you get the label. If not, you get "custom" instead of a wrong answer - which is the right design call. An image that's 1.63:1 is neither 16:10 nor 3:2, and pretending otherwise would poison anything downstream that trusts the label.
The delimiter input (default :) is a neat touch: it's swapped into both the ratio label and the resolution string. Set it to "x" and the label becomes 16x9 and resolution becomes something like 2048x1152 - handy if you're piping this into a node that parses "WxH" text.
The outputs you'll actually wire
- aspect_ratio (STRING) - the bucket label, or
"custom"when nothing fits. Feed this into a text display, a log, or a switch that picks a resolution preset. - resolution (STRING) - dimensions joined by your delimiter.
- width, height (INT) - the real pixel values. These are the workhorses; wire them into a crop, a latent, or an aspect-ratio-aware resize.
Where it fits
The natural companion is the pack's EBU Scaling Resolution node, which has resolution presets organized by aspect ratio. Chain them: this node tells you what bucket your input falls in, the scaling node hands back a matching preset and an upscaled size. Throw EBU Scaling Tile in front of Ultimate SD Upscale and you've got a hands-off upscale pipeline that adapts to whatever image you feed it - the "generate at native resolution, then climb" workflow the upscaling scene has settled on.
Installing
Nothing heavy here. The pack's requirements file literally says "No additional requirements beyond Python standard library" - no torch wheels to juggle, no model downloads. ComfyUI Manager (search "EBU Workflow") or:
cd ComfyUI/custom_nodes
git clone https://github.com/burnsbert/ComfyUI-EBU-Workflow
Then restart ComfyUI. The repo README mentions Python 3.11+, which is the floor, not a special requirement.
Gotchas
- It only looks at the first image in a batch. If you feed a 4-image batch with mixed ratios, you get the first frame's ratio, silently.
- The default 8% tolerance is generous. If you get
"custom"on an image that looks like it should match, nudgetoleranceup - it's a slider from 0 to 1 for a reason. - The node prints a DEBUG line (width, height, ratio, closest match) to the ComfyUI console every run. Fine for learning, mildly noisy if you're running long queues.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| delimiter | STRING | : | — |
| tolerance | FLOAT | 0.080–1 | — |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| aspect_ratio | STRING | — |
| resolution | STRING | — |
| width | INT | — |
| height | INT | — |