Image_Pair_Merge
Combine two images onto one canvas without losing track of either
- image1
- mask1
- image2
- mask2
- mask1_stack
- mask2_stack
- composite_image
- composite_mask
- box2
- new_img2
- new_mask2
Sometimes you want two images to go through a generation or editing pass together - sharing context, composition, lighting - rather than separately, the way side-by-side reference workflows for the newer instruction-editing models do it. Image_Pair_Merge builds that shared canvas, and the part that makes it more than a plain "stick two images together" node is what it hands back alongside the composite: the exact bounding box of where the second image ended up, so a matching Image_Pair_crop can pull just that region back out afterward.
How it works
Per the node's own description, layout_mode covers three families. Left-right and up-down modes put image1 and image2 side by side or stacked, each with center/height/width alignment variants. Centered modes work differently - image2 overlays directly on top of image1 rather than sitting beside it, again with alignment variants controlling how it's centered or scaled. bg_mode picks what fills any space neither image covers (the cropped source, the original image, transparent, white, or a flat color). size_mode and target_size decide how the final canvas dimensions get computed - auto, or locked to a specific output width or height. divider_thickness draws a seam line between the two images in the side-by-side layouts.
The inputs and outputs that matter
layout_modeandbg_mode- the two decisions that shape the whole output; get these right before touching anything else.image1/image2(both optional - you can drive this with just one plus a solidbg_mode),mask1/mask2alongside them.mask1_stack/mask2_stack(optional, typeMASK_STACK2) - Apt_Preset's multi-mask type, for finer control than a single mask.- Output:
composite_image,composite_mask,box2(the tokenImage_Pair_cropneeds - keep this wired), andnew_img2/new_mask2(image2 as it actually landed in the composite, resized and repositioned to match - useful on its own, separate from the full composite).
How to install it
Via ComfyUI Manager: search ComfyUI-Apt_Preset, install, restart. Manually:
cd ComfyUI/custom_nodes
git clone https://github.com/cardenluo/ComfyUI-Apt_Preset.git
Windows: install.bat. Linux/Mac: pip install -r ComfyUI-Apt_Preset/requirements.txt in your venv. Restart. Nothing to download for canvas compositing - the pack's heavier dependencies belong to other parts of this ~300-star, actively maintained pack.
Common issues & troubleshooting
Expected side-by-side, got an overlay. Centered layout modes put image2 on top of image1, not beside it - if that's not what you wanted, switch to a left-right or up-down variant instead.
Can't get image2's region back afterward. Keep box2 wired all the way to Image_Pair_crop, the same way you'd keep a stitch token alive elsewhere in this pack. Without it there's no record of where image2 was once the composite has been through whatever processing happens in between.
Composite looks wrong with two very differently-sized source images. size_mode/target_size decide the final canvas, but extreme size mismatches between image1 and image2 are still worth checking manually before merging - resize one to a sensible scale relative to the other first if the result looks lopsided.
Inputs (11)
| Name | Type | Default | Description |
|---|---|---|---|
| layout_mode | COMBO | 10 options: 左右-中心对齐, 左右-高度对齐, 左右-宽度对齐, 上下-中心对齐, 上下-宽度对齐, 上下-高度对齐, +4 | |
| bg_mode | COMBO | 8 options: crop_image, image, transparent, white, black, red, +2 | |
| size_mode | COMBO | 3 options: auto, 输出宽度, 输出高度 | |
| target_size | INT | 51264–4096 | — |
| divider_thickness | INT | 00–20 | — |
| image1opt | IMAGE | — | |
| mask1opt | MASK | — | |
| image2opt | IMAGE | — | |
| mask2opt | MASK | — | |
| mask1_stackopt | MASK_STACK2 | — | |
| mask2_stackopt | MASK_STACK2 | — |
Outputs (5)
| Name | Type | Description |
|---|---|---|
| composite_image | IMAGE | — |
| composite_mask | MASK | — |
| box2 | BOX2 | — |
| new_img2 | IMAGE | — |
| new_mask2 | MASK | — |