Image Edit Stitch
Build the reference | edit layout that edit models actually want
- reference_image
- edit_image
- edit_mask
- image
- mask
- split_mask
The modern image-edit model (Qwen-Image-Edit, Flux Kontext, and friends) doesn't take "here's my prompt, change the thing" - it takes a tiled image: original on one side, edited result on the other, and it learns from the pair. That's where Image Edit Stitch earns its keep: it glues your reference image and your edited image side by side (or top/bottom) into the exact layout those models expect, with spacing and sizing handled.
It's from ComfyUI 1hewNodes (solo dev 1hew, bilingual README, active v3.x). If you're doing instruction-editing workflows, this is one of the pack's most directly useful nodes - it encodes the "crop, edit, stitch back" loop the KB's inpainting docs describe as the standard Qwen pattern.
How it works
You feed reference_image (the original) and edit_image (your edited version), pick which side the edit goes on with edit_image_position (top/bottom/left/right), and the node stitches them into one canvas. spacing inserts a gap colored by spacing_color, which keeps the two halves from visually bleeding into each other - important because the edit model is literally reading the border.
Sizing is handled two ways. With match_edit_size on, the reference is resized (with padding in pad_color) to exactly match the edit image's dimensions, so the two halves align pixel-for-pixel. With it off, the reference is scaled preserving its aspect ratio to fit alongside the edit - you keep the original proportions and eat whatever padding is needed. For a strict before/after comparison, keep match_edit_size on.
The two extra mask outputs make the node genuinely clever. mask is the combined layout mask (white = reference + edit regions in the stitched canvas). split_mask is a mask that's 1 exactly where the edit image sits and 0 over the reference - meaning after you run the whole stitched thing through an edit model, you can use split_mask to cut the edited half back out and composite it onto your original, untouched. That's the full loop, in one node.
The inputs that matter
- reference_image / edit_image - the two halves. (One can be omitted; the node then just passes the other through.)
- edit_image_position - where the edit half goes.
- match_edit_size - force exact size match vs. preserve reference aspect.
- spacing / spacing_color - the gap and its color.
- pad_color - fill for resizing padding.
Outputs: image, mask, split_mask.
Installing it
ComfyUI Manager → search "1hew" / "ComfyUI 1hewNodes" → install → restart. Manual:
cd ComfyUI/custom_nodes
git clone https://github.com/1hew/ComfyUI-1hewNodes
Pack requirements are heavy (opencv, scikit-image, ultralytics, rembg for other nodes) - first install is slow, but this node only needs numpy/PIL/torch. No models. Needs current ComfyUI (modern node API).
Gotchas
- Edit models are picky about total size - the stitched canvas is twice the width of your input. Make sure it stays inside the model's resolution limits, or size your inputs down first.
match_edit_sizeoff gives you padding - and you must rememberpad_color, because a black pad will read as "content" to some edit models.- Split mask orientation -
split_maskmarks the edit side as 1. If you composite that onto your original thinking it's the reference half, you'll get the wrong thing. Trust the field name.
Inputs (8)
| Name | Type | Default | Description |
|---|---|---|---|
| reference_image | IMAGE | — | |
| edit_image | IMAGE | — | |
| edit_image_position | COMBO | right | 4 options: top, bottom, left, right |
| match_edit_size | BOOLEAN | false | — |
| spacing | INT | 00–1000 | — |
| spacing_color | STRING | 1.0 | — |
| pad_color | STRING | 1.0 | — |
| edit_maskopt | MASK | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| mask | MASK | — |
| split_mask | MASK | — |