π Stitch Images and Mask
Stitch images with their masks, and split them back clean
- image1
- mask1
- image2
- mask2
- unstitch
- IMAGE
- MASK
The plain StitchImages node gets you the stitch-edit-unstitch workflow, but there's a hole in it: once you've edited a composite, how do you know where to paste the result back? That's what the mask is for. This node is StitchImages with a mask lane - it stitches two images and their masks into matching composites, so your edit workflow gets a precise alpha boundary to composite against.
This is the version the pack's own FaceSwap example uses. The pattern: stitch a face image and a body/target image side by side (each with its own mask), edit the composite with an inpainting or face model, unstitch with UnstitchImagesAndMask, and paste the edited region back over the original using the mask that came back with it. Everything stays aligned because the mask goes through the same resize/pad/crop as the image.
How it works
Same alignment machinery as StitchImages - batch alignment, size matching, spacing - but applied to both images and masks in lockstep:
- mask1 and mask2 are optional. Missing masks default to zeros (all-foreground), which is the safe default if you only care about compositing the image.
- When
match_sizeis on, images are resized and masks are resampled (nearest-neighbor, so mask edges don't blur). - The mask lane even gets its own spacing block, so the mask composite lines up pixel-for-pixel with the image composite.
Outputs: the unstitch metadata, the stitched IMAGE, and the stitched MASK.
Inputs
- image1 (required), plus optional mask1, image2, mask2.
- direction (right/down/left/up), match_size, spacing_width, spacing_color - same as StitchImages.
Install
ComfyUI Manager (search "YarvixPA") or
cd ComfyUI/custom_nodes
git clone https://github.com/YarvixPA/ComfyUI-YarvixPA
restart. It's under ComfyUI-YarvixPA/Image/Stitch.
Worth knowing
The mask output is a genuinely useful thing to grab even if you don't plan to unstitch - a stitched mask lets you composite the entire edited composite back over the original scene with one mask, instead of tracking two halves. And the same caveat as its sibling applies: with match_size on, the second image (and its mask) get resized, so treat this as a compositing tool, not a lossless round-trip. If you wire the unstitch metadata into UnstitchImagesAndMask, it remembers the original shapes and direction for you - the metadata is the part of this pack that saves you from rebuilding alignment math every time.
Inputs (8)
| Name | Type | Default | Description |
|---|---|---|---|
| image1 | IMAGE | β | |
| direction | COMBO | right | 4 options: right, down, left, up |
| match_size | BOOLEAN | true | β |
| spacing_width | INT | 00β1024 | β |
| spacing_color | COMBO | white | 5 options: white, black, red, green, blue |
| mask1opt | MASK | β | |
| image2opt | IMAGE | β | |
| mask2opt | MASK | β |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| unstitch | UNSTITCH | β |
| IMAGE | IMAGE | β |
| MASK | MASK | β |