π Stitch Images
Sew two images together, edit, and cut them back apart
- image1
- image2
- unstitch
- IMAGE
There's a workflow pattern that quietly became the standard way to do high-res targeted edits: stitch two images side by side, run the whole composite through a model, then cut the result back apart and paste the edited half over the original. It's how you get a small region regenerated at full resolution without the model downscaling your whole frame. This node is the first half of that trick - it stitches two images into one composite, and it remembers exactly how it did it so a companion node can undo it later.
What makes it different from a plain torch.cat-style image join is the UNSTITCH output. That's not an image - it's a little bundle of metadata recording the direction, the original shapes, and any spacing. You keep it, wire the composite into whatever editing you're doing, and hand both to the pack's UnstitchImages node to slice the edited composite back into its two halves.
How it works
The two images are aligned and joined along the direction you pick - right, down, left, or up. Before joining it handles the boring-but-necessary alignment:
- match_image_size (default on) resizes the second image to match the first, preserving its aspect ratio. Turn it off and mismatched images get center-padded to equal dimensions instead.
- Batch counts and channel counts are aligned too, so a 4-image batch and a 1-image batch still join cleanly.
- spacing_width adds a gap between them, filled with spacing_color (white/black/red/green/blue) - useful when you want a visible seam or a margin for the editing model.
Outputs are the unstitch metadata and the stitched IMAGE.
Inputs
- image1 (required) - the first image.
- direction - right/down/left/up.
- match_image_size - resize image2 to image1's size, or pad.
- spacing_width / spacing_color - optional gap.
- image2 (optional) - if you leave it empty, the node passes image1 through untouched and just hands back the metadata.
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.
The gotcha nobody mentions
With match_image_size on, the second image is resized. So if you unstitch after editing and paste the second half back over the original, you're pasting at the new size, not the original pixels. This is a compositing workflow, not a lossless round-trip - if you need the outside of the mask to stay bit-identical, make image1 the half you keep pristine and image2 the half you'll replace. And remember the UNSTITCH metadata only works with this pack's UnstitchImages - don't lose that wire, or the composite is just a picture.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| image1 | IMAGE | β | |
| direction | COMBO | right | 4 options: right, down, left, up |
| match_image_size | BOOLEAN | true | β |
| spacing_width | INT | 00β1024 | β |
| spacing_color | COMBO | white | 5 options: white, black, red, green, blue |
| image2opt | IMAGE | β |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| unstitch | UNSTITCH | β |
| IMAGE | IMAGE | β |