Nodes/ComfyUI_Fill-Nodes/FL Inpaint Crop
ComfyUI Node

FL Inpaint Crop

FL_InpaintCrop — crop-and-stitch inpainting so the rest of your image survives untouched

By filliptm·Created 3 years ago·Updated about 4 hours ago· 628
FL Inpaint Crop
  • image
  • mask
  • optional_context_mask
  • stitch
  • cropped_image
  • cropped_mask
context_factor1.20
target_size1024
resize_modebucket
force_squarefalse
divisible_by8
invert_maskfalse
fill_mask_holestrue
use_gpufalse

If you've done any inpainting in ComfyUI, you've hit the two problems this node exists to kill. One: a 64-pixel eye gets 64 pixels of generation budget, so the fix comes back mushy. Two: running the whole frame through the sampler means the VAE encode/decode cycle quietly degrades everything, not just the bit you masked. FL_InpaintCrop is Fill-Nodes' take on the crop-and-stitch pattern that's become the default way to inpaint in 2026, and it solves both.

The idea: instead of inpainting in place, it crops a region around your mask - with some surrounding context - and resizes that crop up to your model's native resolution. Now that tiny eye gets a full 1024px of generation budget. You run your inpaint sampler on the crop, then a partner node (FL_Inpaint_Stitch) pastes the result back exactly where it came from. Everything outside the mask never touches the sampler, so it comes back bit-for-bit identical. That's the whole trick, and it turns the community's oldest inpainting rule - always composite after inpainting - from a discipline you have to remember into a property of the graph.

How it works

FL_InpaintCrop reads your image and mask, expands the crop box by context_factor so the model has surroundings to blend against, snaps the dimensions to something the model likes, and hands you back a cropped image, a cropped mask, and an opaque stitch bundle. That stitch object carries the coordinates and scaling needed to reverse the operation. You do your generation on cropped_image, then feed the stitch bundle plus your result into FL_Inpaint_Stitch to recompose.

The inputs that matter

  • image and mask - the full image and where you want to regenerate.
  • context_factor (1.0–3.0, default 1.2) - how much area around the mask to include. More context blends better but spends budget on stuff you're not changing. 1.2–1.5 is a sane range.
  • target_size (default 1024) - the resolution the crop gets scaled to. Match your checkpoint: 1024 for SDXL/Flux, 512 for SD 1.5.
  • resize_mode - bucket (snap to standard resolution buckets), max_dimension, or none.
  • fill_mask_holes (default on) and invert_mask - mask cleanup conveniences.

Outputs: stitch (hand this to FL_Inpaint_Stitch), cropped_image (feed your sampler), and cropped_mask.

How to install it

Part of filliptm's Fill-Nodes pack. ComfyUI Manager → search ComfyUI_Fill-Nodes → Install → restart, or:

cd ComfyUI/custom_nodes
git clone https://github.com/filliptm/ComfyUI_Fill-Nodes
pip install -r ComfyUI_Fill-Nodes/requirements.txt

No model download for this node - it's geometry and masking. The use_gpu toggle just moves the hole-filling to CUDA.

Common issues & troubleshooting

You need the stitch node too. FL_InpaintCrop is one half of a pair. The stitch output is meaningless on its own - it exists to feed FL_Inpaint_Stitch, which puts your generated crop back into the original. Wire both or you've only done half the job.

Scale or style mismatch after stitching. If the fixed region looks like it belongs to a different image, your target_size probably doesn't match the checkpoint's native resolution, so the crop got scaled to a size the model wasn't trained for. Match them. A touch of feather/blur on the mask edge also helps the seam disappear.

Modern edit models drift even through this. Crop-and-stitch guarantees the unmasked pixels survive, but instruction-editing models (Qwen-Edit, Flux Kontext) can still shift things inside the crop or come back slightly misaligned - which is exactly the weakness this pattern was popularized to contain. If you're using one of those, the crop keeps the drift boxed into the region you meant to change instead of letting it leak across the whole frame.

Category🏵️Fill Nodes/Utility

Inputs (11)

NameTypeDefaultDescription
imageIMAGE
maskMASK
context_factorFLOAT1.201–3
target_sizeINT10240–4096
resize_modeCOMBObucket3 options: none, max_dimension, bucket
force_squareBOOLEANfalse
divisible_byINT81–32
invert_maskBOOLEANfalse
fill_mask_holesBOOLEANtrue
use_gpuBOOLEANfalse
optional_context_maskoptMASK

Outputs (3)

NameTypeDescription
stitchSTITCH
cropped_imageIMAGE
cropped_maskMASK