๐ผ๏ธ Ratio Outpaint Calc
Aspect-ratio outpainting without doing the padding math by hand
- image
- image_padded
- mask
You have a square portrait you want to extend to 16:9. The model part of that is the easy part. The boring part - working out how much to pad, on which side, in what colour, and building the mask that tells the sampler where it's allowed to invent - is exactly what this node does for you. Pick a ratio, and it hands you a padded image plus a ready-to-use mask, wired straight into VAE Encode (Inpaint).
It's the simplest node in the aioli pack, and that's fine. For a single whole-frame outpaint it replaces the three or four maths/text nodes people usually stack for this, and it doesn't leak your aspect-ratio mistakes into the result. If your source image absolutely has to survive byte-for-byte, the crop-and-stitch path (BBoxMultipleFix โ KSampler โ ImageCompositeMasked) is the one from this pack that guarantees that; this node sends the whole frame through the model. Use it when you're fine with the original being re-encoded, which is most outpainting.
How it works
The node takes your image and figures out the smallest canvas at the chosen ratio that fits it, pads the difference with neutral grey (0.5), and emits a binary mask where 0 = keep (your original pixels) and 1 = generate (the new border). Grey 0.5 rather than black or white is deliberate: the model isn't nudged toward a dark or bright fill, it just sees "neutral unknown territory." The mask plugs into VAE Encode (Inpaint) exactly like a hand-drawn one.
The multiple dropdown (default 16 (Flux)) snaps the padded dimensions to a multiple the downstream model likes - 8 for a bare VAE minimum, 16 for Flux, 32 for SD1.5, 64 for SDXL. Setting none falls back to the original behaviour of ceiling the computed dimension to a multiple of 8. Keeping the canvas on a model-friendly multiple matters more than people think: many image-edit and inpaint models quietly recrop or letterbox inputs that don't line up, and that's how your "perfectly padded" outpaint comes back a few pixels off.
If you pick ratio: none it's a clean pass-through with a zero mask - handy for toggling the branch off without rewiring.
Inputs and outputs
Only three inputs, and really only ratio and multiple matter:
image- your source.ratio-noneยท1:1ยท4:5ยท5:4ยท3:4ยท4:3ยท16:9ยท9:16.multiple- the alignment snap, default16 (Flux).
Outputs are image_padded (the grey-padded canvas) and mask (the generate-here region).
The canonical wiring: Load Image โ Ratio Outpaint Calc โ VAE Encode (Inpaint) โ KSampler.
Installing it
It ships in the Aioli Nodes pack. In ComfyUI Manager, search "Aioli Nodes" and hit install, or:
cd ComfyUI/custom_nodes
git clone https://github.com/aiolicollective/aioli-nodes
Then restart ComfyUI and the nodes appear under the Aioli Nodes category. No extra dependencies - just math, torch, numpy, scipy and Pillow, all already bundled with ComfyUI. There's no requirements.txt to babysit.
Gotchas
Two things trip people up. First, this node pads, it doesn't generate - a large 16:9 extension at high denoise has the model inventing a lot of new scene, and that can look dreamt-up. That's normal outpainting behaviour, not a bug; dial denoise down for conservative extensions. Second, if you get a visible seam where the fill meets the original, don't blame the padding - feed the mask through a GrowMask/blur before encoding (the KB's standard 4โ12 px of mask blur). The pack is young and the collective behind it is a small studio, so there's no big community trail of reported issues yet - if you hit something, that's what the GitHub issues page is for.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | โ | |
| ratio | COMBO | 8 options: none, 1:1, 4:5, 5:4, 3:4, 4:3, +2 | |
| multiple | COMBO | 16 (Flux) | 5 options: none, 8 (VAE minimum), 16 (Flux), 32 (SD1.5), 64 (SDXL) |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| image_padded | IMAGE | โ |
| mask | MASK | โ |