Anything Stitch
Put the swapped object back so the seam disappears
- stitch
- swapped
- mask_override
- image
- changed_mask
The third act of object swapping is where most pipelines die: you've got the replacement crop back from your model or API, and now it has to go back into the original photo without a visible border. Anything Stitch is the node for that. It takes the geometry payload from Anything Crop (for Swap) and the edited crop, and composites the swap back in - with feathering, color matching, and the promise that pixels outside the mask come back bit-identical to the original.
That last part is the differentiator. Because the crop node embeds the clean original and exact geometry in the SWAP_STITCH payload, the stitch node can work from ground truth, not from whatever the swap model happened to produce. Nothing outside the changed region gets touched, which is exactly what you want when you're swapping a face in a photo where the rest of the frame must survive untouched.
How it works
Anything Stitch reads stitch (the payload from Anything Crop), takes swapped (the crop your model generated), and composites. The flow is defensive by design:
- If
detectedin the payload was false, it returns the original untouched - no fake stitching. - If the swapped image has an alpha channel (some APIs hand back RGBA), it drops it with a warning.
- It only accepts a single image; a batch throws.
The geometry comes from the payload: crop bbox, pre/post-resize sizes, and source padding all travel inside stitch, so the node doesn't re-derive anything. When the swap model returns a different resolution, size_mismatch decides - resize rescales but rejects an aspect-ratio change, stretch rescales regardless (distorting), error demands an exact match.
The seam handling is where quality lives. feather softens the mask edge, color_match runs a weighted color transfer (reinhard, mkl, or hm) that - cleverly - matches against the original pre-swap crop and weights by the mask, so background pixels in the crop don't drag the correction away from skin tones. changed_mask output tells you exactly which pixels changed at source resolution, handy for a refinement pass.
Inputs and outputs
stitch(SWAP_STITCH) - from Anything Crop. Required.swapped(IMAGE) - your edited crop. Required.mask_override(MASK, optional) - replaces the payload mask if you want control.- Outputs:
image(IMAGE) - the full stitched result;changed_mask(MASK) - the changed region.
Install
Same pack: WorkflowX-Configurator via Manager (WorkflowX Configurator) or:
cd ComfyUI/custom_nodes
git clone https://github.com/haroonaslam/WorkflowX-Configurator
Restart, hard-refresh. No model downloads for the stitch side - the SAM3 model requirement lives with the crop node.
Common issues
- "stitch is not connected" - wire the
stitchoutput from Anything Crop, not something you built yourself. The payload is opaque; you can't hand-assemble it. - Swapped image looks stretched. Your swap model changed the aspect ratio and
size_mismatchwasresize. Switch tostretchonly if the distortion is acceptable, or regenerate at the right aspect. - Seams still visible. Raise
feather, and make surecolor_matchis on. If the color still drifts, lowercolor_match_strengthrather than killing the match - full-strength transfer can overcorrect.
For a genuinely seamless result, the discipline is: feed the crop node good geometry (a hair of expand_factor so the model has context), then let the stitch node's feathering and weighted color match do their job instead of stacking a bunch of post-processing. This pair is the part of WorkflowX that most deserves a try.
Inputs (9)
| Name | Type | Default | Description |
|---|---|---|---|
| stitch | SWAP_STITCH | Payload from Anything Crop. Carries the clean original and exact geometry. | |
| swapped | IMAGE | The edited crop, straight back from your model or API. | |
| size_mismatch | COMBO | resize | What to do when the swap model returns a different resolution. resize: rescale, but reject a changed aspect ratio. stretch: rescale regardless, distorting. error: demand an exact match. |
| mask_mode | COMBO | 3 options: payload_mask, full_rect, override | |
| feather | INT | 60–256 | — |
| color_match | BOOLEAN | true | — |
| color_match_method | COMBO | mkl | 3 options: reinhard, mkl, hm |
| color_match_strength | FLOAT | 1.000–1 | — |
| mask_overrideopt | MASK | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | The full source image with the swapped region composited back in. |
| changed_mask | MASK | Which pixels changed, at source resolution. Feed a refiner pass. |