Nodes/ComfyUI-Fill-Image-for-Outpainting/Fill Image For Outpainting
ComfyUI Node

Fill Image For Outpainting

Pre-fill your outpaint canvas so the model isn't generating into a black void

By Lhyejin·Created 2 years ago·Updated 2 years ago· 9
Fill Image For Outpainting
  • image
  • mask
  • IMAGE
  • MASK
fill_method

Outpainting has a chicken-and-egg problem. To extend an image you mask the empty canvas and let the sampler invent what goes there - but at the boundary, the model is staring at a hard edge where your pixels stop and a black rectangle begins. It has to guess what's behind that line with almost no context, which is why straight-to-sampler outpainting so often comes back with seams, color mismatches, and invented clutter right along the border. Fill Image For Outpainting is the fix for that half of the problem. It's a preprocessing node, not a generator: it fills the masked extension area with pixels borrowed from your image's edges, so the diffusion model sees a continuous picture and only has to extend, not bridge a cliff.

How it works

The node takes your image and mask, then paints the mask region using one of three methods - no neural net, no VRAM, all CPU:

  • cv2_telea - OpenCV's Telea inpainting. Smooth, natural fills. The one I'd reach for first on a photo.
  • cv2_ns - the Navier-Stokes variant. Sharper at structure and edges; nicer if you're extending something with strong lines.
  • edge_pad - despite the name, this one is pure numpy/scipy, no OpenCV. It walks the boundary of your original image and pushes those colors outward into the mask. Fastest by a mile, and the right call for rectangular canvas extensions where you just want the border colors dragged straight out.

That's the whole mechanism, and it's worth knowing it does exactly this and nothing else. The filled output is a smeared approximation of what might be there - which is precisely what makes it useful as conditioning.

The inputs that matter

There are only three, and they're all required: image, mask, and fill_method (the dropdown above). Outputs are an IMAGE - the filled canvas - and a MASK, which is just your mask passed back through so you can wire it onward without splitting wires.

Keep standard ComfyUI mask polarity: white = the region to fill. One trap: edge_pad inverts the mask internally because it needs to know which pixels are known before smearing them. Don't "fix" the polarity for it - feed the same white-on-the-void mask to all three methods and let the node do its thing.

Where it goes in the workflow

The pattern, from the pack's README (it links a Flux-dev outpainting workflow): pad your canvas with a pad node (e.g. ImagePadForOutpaint), mask the empty area, run this node to fill it, then feed the filled image into your inpaint conditioning - InpaintModelConditioning gets the filled image as the inpaint/reference image and the mask on its mask input - and sample at denoise 0.8–1.0. The mask output composites cleanly back over the original afterward. Outpaint with a generous mask overlap over the original's edge and a blur or two, and the seams mostly stop being a problem.

Worth the honest note: outpainting is the one job instruction editors took cleanly. For a one-off "extend this scene," padding with a solid color and asking Flux Klein or Qwen-Image-Edit to "remove the padding and show what's behind it" is two nodes and often better. The masked route this node serves wins when the original must survive byte-for-byte - the model never touches unmasked pixels - or when you're extending in multiple passes where whole-frame drift compounds.

Install

Easiest: ComfyUI Manager → search "ComfyUI-Fill-Image-for-Outpainting" → install, restart. Or the manual route:

cd ComfyUI/custom_nodes
git clone https://github.com/Lhyejin/ComfyUI-Fill-Image-for-Outpainting.git
cd ComfyUI-Fill-Image-for-Outpainting
pip install -r requirements.txt

No model files, no downloads, no key. Dependencies are just opencv-python==4.8.1.78 and SciPy==1.11.4 - both pinned exact. That pinning is the one real gotcha: if your ComfyUI venv already has newer versions, pip will try to downgrade and can fight other nodes, and SciPy 1.11.4 has no wheels for the newest Python interpreters. If it misbehaves, drop the pins (pip install opencv-python scipy) - the code doesn't need those exact versions. Also, the node processes one frame at a time (image[0]), so don't feed it a batch and expect the whole stack back. For single-canvas outpainting you never notice.

Categoryimage

Inputs (3)

NameTypeDefaultDescription
imageIMAGE
maskMASK
fill_methodCOMBO3 options: cv2_ns, cv2_telea, edge_pad

Outputs (2)

NameTypeDescription
IMAGEIMAGE
MASKMASK