Compose Image Regions
Stitch the crops back without losing the edges
- original
- edited
- original_regions
- layout
- image
- image_list
Crop, edit, stitch is the dullest and most reliable trick in the 2026 toolbox: cut the part you want to change out of the frame, run a modern edit model on the crop, and paste the result back so the rest of the image is bit-identical. Inpaint-CropAndStitch owns the mask-shaped version of this. Compose Image Regions is the named-rectangles version, for when you drew boxes around a face, a logo, a sleeve and a shoe instead of painting a mask.
It's the second half of a pair. LF_ExtractImageRegions cuts the boxes onto square canvases; this one takes the edited canvases back and writes the changes into the original.
How it works
This node transfers RGB deltas, not replacement crops. It compares each edited canvas against the baseline canvas the editor was handed, ignores anything within one 8-bit step (plus float epsilon - that's PNG transport noise, not you), resizes what's left down onto the native rectangle, and applies it to the source only where it's non-zero. Unchanged regions, uncovered pixels and anything outside the resampling footprint stay bit-exact.
The original alpha channel is always retained, even if you painted alpha in the editor. That's deliberate: the regions path is RGB-only, and alpha belongs to the source.
It also validates rather than trusts. Your original_regions baseline is checked against the extraction - same source, same order, same canvas geometry - and a mismatch is an error, not a quiet mis-stitch.
The inputs and outputs that matter
original- exactly one image, the same one you fed to Extract Image Regions. Alpha retained.edited- the edited canvases in validated original order. In practice this is the breakpoint'simage_list.original_regions- the breakpoint'sorig_image_list, same order. Drop this and there are no local deltas, only guesses.layout- the JSON from Extract Image Regions. It carries the source dimensions and the content rectangles that make the projection possible.
Outputs are image (the full-size result, a one-image batch) and image_list (a single-item list, for downstream nodes that insist on list input). Nothing is written to disk - save it yourself.
Note the order dependency: you must keep the editor's ordered outputs. Unlabelled raw tensors can't independently prove which edit goes with which region, and the node says so in the tooltip. Named entries exist precisely to carry that identity.
How to install it
ComfyUI Manager → search LF Nodes → install → restart, or:
cd ComfyUI/custom_nodes
git clone https://github.com/lucafoscili/lf-nodes
python -m pip install -r lf-nodes/requirements.txt
Pip with ComfyUI's interpreter. One trap for this pack: the author retired the old lucafoscili/comfyui-lf repo in October 2025 and moved to lf-nodes, and a lot of older posts still link the dead one. This node's own needs are basic - Pillow and numpy, both already in the pack's requirements.
Common issues & troubleshooting
"Mismatched source/order" or canvas-geometry errors. The compositor refuses when the baseline doesn't match the extraction. Usually it's a reorder in the editor, or one region edited in a different run. Re-run the pair together.
The stitch is invisible. Two candidates: your edit was within the one-step tolerance, or you edited padding rather than content. Only the aspect-fit content rectangle is projected back; edits outside it are discarded by design.
A hairline seam appears around a region. Expected and bounded. The delta is resized with bilinear antialiasing, so interpolation can touch pixels just outside the box. Cheap fix: leave a few pixels of margin around each rectangle when you draw it in the first place, so the footprint lands on pixels you didn't care about.
Overlapping rectangles. Not supported here - Extract Image Regions enforces non-overlap. If your regions genuinely need to layer, that's what the image-layers pair is for.
Alpha changes disappeared. By design. This path keeps the original alpha; use the layers workflow if coverage is what you're editing.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| original | IMAGE | Exact single source image used for extraction; alpha is retained. | |
| edited | IMAGE | Edited canvases in validated original entry order. | |
| original_regions | IMAGE | Breakpoint orig_image_list, in the same order; required for local edit deltas. | |
| layout | JSON | Layout returned by Extract Image Regions. |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | Original image with region RGB edit deltas; alpha and untouched pixels retained. |
| image_list | IMAGE | Single-item list containing the composed image. |