stitch
The Stitch Node Is the Glue Nobody Searches For — Here's What It Actually Does
- image
- IMAGE
You will almost never search for stitch on purpose, because it's not the kind of node you discover - it's the one that shows up at the end of a workflow you loaded from a JSON file and quietly does the job you didn't know needed doing. It's the final step in this pack's browser-canvas inpaint/outpaint flow: after the LCM nodes render the masked or expanded region, stitch is what sews that rendered region back into the full image so you get one clean output instead of a crop and a background you have to reassemble by hand. Zero Google impressions says it all - this is a supporting actor, not a star.
How it works
The mechanism is sneaky for a node with a single input. You feed it one image (the region you just generated), and instead of just pasting it, it phones home to a locally-running Flask canvas server - the CanvasTool that ships in this pack - and asks for the state of your editing session. It fetches savedata (the outpaint expansion dims and crop geometry you set in the canvas editor) plus the masked background and the mask itself, then composites: it builds a fresh RGBA canvas sized to the background plus your left/right/top/bottom outpaint margins, pastes the background in, and pastes your rendered image on top at the exact crop coordinates the editor recorded, using the mask for the blend. One IMAGE comes out the other side.
The one detail that bites: the node reads two environment variables, LISTEN and CANVASPORT, to find that canvas server. If they're not set, it dies with a KeyError before doing anything. The Flask app itself defaults to localhost:5000, so on most setups you need something like LISTEN=127.0.0.1 CANVASPORT=5000 in the environment that launches ComfyUI.
Inputs and outputs
That's the whole surface: one required image input (the inpainted/outpainted region), one IMAGE output (the final stitched composite). Wire the output of the pack's inpaint/outpaint pipeline into it, and its output into a preview or save node. There's nothing to tune - it's pure geometry and PIL compositing, no sampler or model involved.
Installing it
stitch ships in the LCM_Inpaint-Outpaint_Comfy pack, so install the whole thing. ComfyUI Manager can find it by the pack title, or:
cd ComfyUI/custom_nodes
git clone https://github.com/taabata/LCM_Inpaint-Outpaint_Comfy
cd LCM_Inpaint-Outpaint_Comfy
pip install -r requirements.txt
The requirements are diffusers, tomesd, compel, Flask, and icecream - nothing exotic. The LCM nodes also want the diffusers-format LCM_Dreamshaper_v7 model from HuggingFace in models/diffusers/, though stitch itself doesn't touch it. For the canvas flow you also need the README's setup step:
cd ComfyUI/custom_nodes/LCM_Inpaint_Outpaint_Comfy/CanvasTool
python setup.py
Careful: that script copies the pack's server.py and index.html over ComfyUI's own files in the root and web/ directories - it effectively swaps ComfyUI's frontend for the canvas editor. Back those files up first, and remember to restore them if you uninstall.
The honest gotchas
This is an early-LCM-era pack (the original Reddit post is October 2023, last commit late 2024), and it's built the way a solo dev builds for themselves. The code is full of hardcoded absolute paths - a sibling node literally returns "/home/mohammad/reference.png" - and the README itself warns that paths are formatted for Linux and Windows users will hit errors. If you're not running the author's exact workflow, expect to set those env vars, fix a path, and possibly pin older diffusers because the pipelines predate a lot of API churn.
If your only goal is masked inpainting, you don't need this pack - ComfyUI's own tooling and newer edit models cover most of it now. But if you specifically want the thing masks still uniquely own - bit-identical unmasked pixels and exact placement - this little glue node is what delivers it. Just don't expect a hand to hold.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |