Outpainting Pad
The math for a bigger canvas
- image
- left
- top
- right
- bottom
Outpainting starts with a boring but critical step: your source image needs to sit on a bigger canvas, and something has to decide where. Outpainting Pad doesn't pad the image itself - it computes the padding amounts and hands them to you as four integers (left, top, right, bottom), which you feed into your actual pad/expand node. It's the calculator in the outpainting pipeline.
That split is deliberate and useful. The padding math is the fiddly part - center a 512×512 image on a 1024×1024 canvas and the top and bottom offsets are each 256, but with odd sizes or off-center alignment the remainder handling gets ugly. This node does the division and remainder bookkeeping for you, in all nine alignments, so your pad node just consumes the numbers.
Inputs and outputs
image(IMAGE) - the source whose dimensions drive the math.target_width,target_height(INT) - the destination canvas size, 64–8192.align- nine positions:left,left-top,top,top-right,right,right-bottom,bottom,left-bottom, andcenter(default).left,top,right,bottom(INT) out - the four padding amounts.
How it works
It reads the image's width/height, then computes each side's padding so the image lands where align says, distributing any remainder correctly. If the image is already larger than the target, it raises a clear error (Image size is larger than target size) instead of silently producing negative padding - good behavior, and the message tells you both sizes.
Where it fits
Right before the pad step in any extension workflow. The KB's inpainting doc tracks the popular no-mask trick - pad the canvas with a solid color and prompt the model to fill it - and this node is the natural way to compute that pad. Wire its four outputs into a pad node (or drive your own with Pure Color Image), keep the source centered, and let the sampler extend outward. Pair it with masking or an extend-capable model like FLUX.1 Fill for the full workflow.
Install
FairLab, one pack: ComfyUI Manager (search ComfyUI-FairLab) or:
cd ComfyUI/custom_nodes
git clone https://github.com/yanhuifair/ComfyUI-FairLab.git
cd ComfyUI-FairLab
pip install -r requirements.txt
Restart, then look under Fair/image. No extra dependencies.
Gotchas
- It computes padding; it does not pad. The four INTs are inputs to another node - skip that step and nothing visibly happens, which confuses people once.
- Target smaller than source hard-errors with the two sizes printed, so you get a clear message rather than nonsense padding.
- If your pad node needs a single "all sides" number (for uniform padding), you're better off computing it yourself - this node's whole point is the non-uniform, alignment-aware case.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| target_width | INT | 102464–8192 | — |
| target_height | INT | 102464–8192 | — |
| align | COMBO | center | 9 options: left, left-top, top, top-right, right, right-bottom, +3 |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| left | INT | — |
| top | INT | — |
| right | INT | — |
| bottom | INT | — |