Smart Image Stitch
Put the crop back so nobody can see the seam
- original_image
- processed_image
- stitcher
- mask
- image
- info
The half everyone forgets
The KB's inpainting doc has a quote that's now eight years old in internet terms and still the most repeated piece of advice in the field: "PLEASE composite your image after inpainting." A regenerated crop dropped in un-composited leaves a rectangle of slightly-different colour, slightly-different grain and slightly-different geometry sitting inside your frame. Three passes like that and the image is trash.
Smart Image Stitch is the compositing half of the crop pipeline: take the processed crop, put it back exactly where it came from, and blend the boundary so the join doesn't announce itself. It's the counterpart to Smart Image Crop (MEC) in this pack and consumes the STITCHER payload that node emits - the geometry of the crop (position, size, pad offsets, original dimensions), recorded so the paste can be undone precisely.
Inputs
- original_image - the full frame before the crop. This is what everything outside the crop rect comes from, untouched.
- processed_image - the crop after your model got to it. It's resized back to the recorded crop size, so don't pre-resize it.
- stitcher - from
Smart Image Crop. Required, and it's a realSTITCHERtype, so wiring the wrong thing gives you a legible error instead of a crash three nodes later. - feather_pixels - 0–256, default 32. The width of the transition.
- blend_mode - three options and each has a distinct job:
- Box Feather (default) - softens the crop's rectangular boundary. Use it when the model changed the whole crop.
- Mask Feather - blends along the mask instead of the rectangle, which keeps untouched detail outside the subject. This is the one you want for a face or a product fix, because the seam follows the subject rather than cutting through the background.
- Hard Paste - no feather. It shows the seam, which is exactly why it's useful: it's your alignment check. If the geometry is right, Hard Paste looks almost clean; if it's off, you'll see a doubled edge and know immediately that the problem is upstream and not in your blend.
- resize_full_image_output -
Restore Original SizeorKeep Resized Image. Only relevant when the crop node ran inResize Full Imageno-mask mode. - enable_color_match and color_match_amount (default 0.35) - a mean/std colour transfer that pulls the crop's exposure and cast toward the plate before blending. The tooltip gives the reason it exists: a feathered seam turns a small colour mismatch into a visible halo instead of hiding it. The KB's post-processing doc calls this the correct tool for exactly this job - make a composited element agree with its surroundings with a deterministic statistics transfer instead of re-generating and hoping. Start at 0.35 and go up only if you still see a tint step; too much and the crop loses its own light.
- mask (optional) - the mask to blend along in
Mask Feathermode. Wire the samecrop_maskthe crop node emitted. Without one, Mask Feather can't do its thing, and the info string says so rather than pretending it worked.
Outputs: image and info - the latter reporting how many regions were pasted and which blend mode ran, which is the string you read when the result looks wrong and you can't tell whether the blend or the geometry is at fault.
The pipeline
[Load Image] + [Mask] → [Smart Image Crop (MEC)]
├── crop_image ─→ (sampler / edit model / upscaler)
├── crop_mask ─────────────────┐
└── stitcher ─────────────────┐ │
↓ ↓
[Smart Image Stitch (MEC)]
blend_mode: Mask Feather
feather_pixels: 32
enable_color_match: true
↓
final frame
A round-trip test in the pack's own suite asserts that crop-then-stitch puts the crop back where it came from, and that a bypassed stitcher returns the original untouched - so if you're seeing a global shift, it's upstream of this node, not in it.
Install
ComfyUI Manager → search "CustomNodePacks", or:
cd ComfyUI/custom_nodes
git clone https://github.com/Code2Collapse/ComfyUI-CustomNodePacks
Restart ComfyUI. Tier 1: no models, no VRAM beyond the tensors themselves. Pack dependencies are opencv-python, scipy, safetensors - OpenCV is optional here but needed for the best seams. As the README says, check pip list before installing the pack's requirements rather than overwriting ComfyUI's bundled torch.
Common issues
- A visible rectangular seam. You used Box Feather and the model changed the subject - the rectangle cut through the background. Switch to Mask Feather with the crop mask wired.
- A soft halo around the subject. Colour mismatch being feathered into visibility. Turn
enable_color_matchon, or raisecolor_match_amounta little. - The whole frame shifted by a few pixels. Geometry mismatch from a resized full image: check
resize_full_image_outputagainst what the crop node did. - Mask Feather did nothing. No mask connected. Read the info string; the node tells you.
Inputs (9)
| Name | Type | Default | Description |
|---|---|---|---|
| original_image | IMAGE | — | |
| processed_image | IMAGE | — | |
| stitcher | STITCHER | — | |
| feather_pixels | INT | 320–256 | — |
| blend_mode | COMBO | Box Feather | Box Feather softens the crop's rectangular edge. Mask Feather blends along the mask itself, which keeps untouched detail outside the subject. Hard Paste shows the seam and is for checking alignment. |
| resize_full_image_output | COMBO | Restore Original Size | Only applies when the crop node ran in 'Resize Full Image' mode. |
| enable_color_match | BOOLEAN | false | Pull the crop's exposure and cast toward the plate before blending. A feathered seam turns a small mismatch into a visible halo instead of hiding it. |
| color_match_amount | FLOAT | 0.350–1 | — |
| maskopt | MASK | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| info | STRING | — |