ComfyUI Node

Smart Mask Stitch

Smart Mask Stitch — paste a masked edit back without the rectangle showing

By amortegui84·Created 5 months ago·Updated 3 months ago· 3
Smart Mask Stitch
  • stitcher
  • edited_image
  • image
edge_feather_percent3.0
result_mask_feather_percent0.0

The NB2 path in this pack composites a generated rectangle back onto the image, and that's fine - but for editors that accept a real mask, like GPT Image, you have something better to blend with: the actual shape of what you edited. Smart Mask Stitch uses that stored local mask as the primary blend, so the transition follows the object's edges rather than a rectangle's.

This is the paste half of the pack's "local masked edit" path. The crop half is Smart Mask Crop, which hands a cropped region plus a cropped mask to GPT Image or another mask-based editor; this node takes the edited result and the stitcher bundle and puts it back where it belongs.

Inputs

  • stitcher - coordinate data from Smart Mask Crop. It carries where the crop came from and the stored local mask used for blending. No stitcher, no paste.
  • edited_image - the output of the local masked editor (e.g. NB2OpenAIImageEdit's images).
  • edge_feather_percent (0–50, default 3) - extra feather applied to the local crop's boundary, for when the crop rectangle itself would show at the edges.
  • result_mask_feather_percent (0–100, default 0) - extra blur on the stored local mask that drives the final blend. This is the knob to reach for when the paste edge looks too hard - nudge it up from 0 and the edit melts into the original instead of stopping at a sharp boundary.

Output is a single image: the original with the edit blended in along the mask.

The flow it closes

Florence-2 or SAM selector -> mask -> Smart Mask Crop
    -> cropped_image      -> GPT Image Edit (image_1)
    -> cropped_mask_image -> GPT Image Edit (mask_image)
    -> edited result -> Smart Mask Stitch -> final image

The key pairing: wire Smart Mask Crop's cropped_mask_image into the editor's mask_image so the model edits only the masked shape, then Smart Mask Stitch blends back along the same mask. If the edit's mask and the stitch's mask disagreed, you'd get a paste that changes things it shouldn't - the pack's design keeps them consistent by construction.

Install & gotchas

Search comfyui-inpaint-cropstitch-nb2 in ComfyUI Manager or:

cd ComfyUI/custom_nodes
git clone https://github.com/amortegui84/comfyui-inpaint-cropstitch-nb2

Restart. This node is local - no key. The edit node upstream is where FAL_KEY comes in.

Two things to check when the paste looks wrong. First: if you changed target_size_mode or target_aspect_ratio on Smart Mask Crop after the editor ran, the crop and the edit are different sizes - rerun both, or the stitch resamples. Second: a hard edge that edge_feather_percent won't fix usually means the editor ignored the mask and rewrote the whole crop; that's a prompting problem, and the fix is in the editor's instructions ("retouch only the masked region, preserve everything else"), not in the stitch settings.

Categoryinpaint/masked

Inputs (4)

NameTypeDefaultDescription
stitcherSTITCHER
edited_imageIMAGE
edge_feather_percentFLOAT3.00–50Extra feather applied to the local crop edge.
result_mask_feather_percentFLOAT0.00–100Softens the stored local mask used to blend the edited result back.

Outputs (1)

NameTypeDescription
imageIMAGE