AspectRatio
Feed it any image, get back the closest SDXL canvas
- image_in
- ratio
- width
- height
Aspect from Image doesn't resize anything, despite the name. It reads the aspect ratio of whatever image you hand it, snaps that ratio to the nearest standard SD15 or SDXL canvas, and hands you three numbers. You then wire those numbers into an Empty Latent Image and generate on a canvas that keeps your source's framing without you having to think about pixels at all.
That's genuinely useful in img2img and re-composition workflows. When you're reusing an image as a starting point, the new canvas should keep the source's feel - and it should be one of the sizes the checkpoint was actually trained on. Stray resolutions work, but SDXL's standard set (1024x1024, 1152x896, 1216x832, 1344x768, 1536x640 and their rotations) is where the model is most comfortable, and where composition is most predictable. This node is a tidy way to land on one of those sizes without typing numbers.
How it works
The code is a nearest-neighbor match against a table. It computes width divided by height for the source image, then compares that ratio against the midpoints between the standard canvases and picks whichever side you fall on. So a source at 1.6:1 slides into the 16:9 bucket, a tall one into the portrait bucket. It never crops, scales, or touches the image - it's a measurement node with a dropdown bolted on.
The two inputs are the whole story: image_in (any IMAGE) and modeltype, where you pick SD15 or SDXL depending on which checkpoint family you're generating with. Same named aspect, different pixel sizes per family - SDXL's 16:9 is 1344x768, SD1.5's is 910x512.
Outputs are ratio (a FLOAT with the source's actual aspect), width, and height (the snapped canvas, as INTs). Wire width and height into an Empty Latent Image and you're done.
One quirk worth knowing: the snap is coarse by design. The ratio output keeps the true source ratio, but width/height come from the fixed table, so a 2:1 panorama lands on the 16:9 canvas, not a custom one. If you need a truly arbitrary ratio, this isn't the node. And while it does support SD1.5, its SD1.5 table is finer-grained (about ten buckets, including some 16:10 and monitor sizes) - most people reaching for this are on SDXL anyway.
It's also the smarter cousin of the pack's Latent Aspect node: that one takes a named aspect and returns the same kind of width/height. Use Aspect from Image when you want to match a source image; use Latent Aspect when you already know which named ratio you want.
Installing it
The pack has no extra dependencies at all - pure PIL/numpy/torch, the same image libraries ComfyUI already ships with. Nothing to download, no requirements.txt to fight with.
- ComfyUI Manager (easiest): search for Comfy_Felsirnodes (or just "Felsir"), install, restart. It's on the Comfy Registry as "Felsir-image-tools."
- Manual:
cd ComfyUI/custom_nodesthengit clone https://github.com/Felsir/Comfy_Felsirnodes, and restart ComfyUI.
You'll find the node under Add Node → Felsir (the author has noted the submenu may eventually move to the image category).
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| image_in | IMAGE | — | |
| modeltype | COMBO | 2 options: SD15, SDXL |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| ratio | FLOAT | — |
| width | INT | — |
| height | INT | — |