FEImagePadForOutpaintByImage
Outpaint onto a canvas you already have
- inner_image
- outer_image
- IMAGE
- MASK
The sibling FEImagePadForOutpaint grows your canvas with a solid color. FEImagePadForOutpaintByImage takes the same idea one step further: it grows the canvas with another image. Instead of telling it "add 512px on the right," you hand it a bigger background image and a smaller image, and it composites the smaller one onto the bigger one - with a feathered mask, ready for the sampler.
This is the node for iterative outpainting, where each pass's output becomes the canvas for the next. You outpaint a scene to the right, then want to extend it upward - you don't want to re-derive the canvas from scratch; you want the previous result preserved underneath. Feed the previous result as outer_image, your new content as inner_image, and you're chaining passes cleanly.
How it works
Two images in: inner_image (the thing that stays sharp) and outer_image (the bigger background it lands on). Then two position pairs:
padding_xpluspadding_xc(leftorright) - horizontal offset. Ifpadding_xcisleft, the inner image sitspadding_xpx from the left edge; ifright, it'spadding_xpx from the right edge.padding_ypluspadding_yc(toporbottom) - same idea vertically.
The math is a bit unusual: when you pick right, the code computes the offset as outer_width − inner_width − padding_x, so padding_x reads as "distance from the right edge." That's genuinely handy for centering or anchoring, but it's the thing most people trip on first.
It then pastes the inner image onto the outer canvas and builds a MASK with the same squared feathering falloff as its sibling - 1 on the background, 0 on the inner image, soft in between. If your two images differ in batch size, it repeats the outer image to match; if they differ in channel count, it raises a clear error.
The inputs that matter
inner_image/outer_image- the composite pair. Outer should be larger, and both should be RGB.padding_x/padding_y- distances,0–8192(note: step 1 here, not 8 - the code doesn't enforce latent-friendly steps, so you may want to snap the total yourself).padding_xc/padding_yc- which edge the distance is measured from.feathering- blend width, default50.
Outputs are the composited IMAGE and the MASK, wired straight into a KSampler's mask input with the inner region protected.
Where people get burned
The classic mistake is forgetting that both branches of an outpaint chain must exist - outer_image has to actually be bigger than inner_image in the direction you're padding, or the math silently produces weird offsets. And since this is the ByImage variant, the whole point is that the background already contains pixels you want to keep; if your outer image is just noise, you'd have been better off with the solid-color version.
Install
Same pack, same story - fexli-util-node-comfyui:
cd ComfyUI/custom_nodes
git clone https://github.com/fexli/fexli-util-node-comfyui
cd fexli-util-node-comfyui
pip install -r requirements.txt
Or via ComfyUI Manager (search fexli-util-node-comfyui), then restart. Nothing heavy to download, no config.yaml needed for this node.
Bottom line: if you only outpaint once, use the solid-color sibling. If you outpaint in stages and want each stage to survive intact, this is the one.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| inner_image | IMAGE | — | |
| outer_image | IMAGE | — | |
| padding_x | INT | 00–8192 | — |
| padding_xc | COMBO | 2 options: left, right | |
| padding_y | INT | 00–8192 | — |
| padding_yc | COMBO | 2 options: top, bottom | |
| feathering | INT | 500–8192 | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |
| MASK | MASK | — |