Nodes/ComfyUI-Apt_Preset/Image_Pair_Merge
ComfyUI Node

Image_Pair_Merge

Combine two images onto one canvas without losing track of either

By cardenluo·Created 2 years ago·Updated 18 days ago· 309
Image_Pair_Merge
  • image1
  • mask1
  • image2
  • mask2
  • mask1_stack
  • mask2_stack
  • composite_image
  • composite_mask
  • box2
  • new_img2
  • new_mask2
layout_mode
bg_mode
size_mode
target_size512
divider_thickness0

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_mode and bg_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 solid bg_mode), mask1/mask2 alongside them.
  • mask1_stack/mask2_stack (optional, type MASK_STACK2) - Apt_Preset's multi-mask type, for finer control than a single mask.
  • Output: composite_image, composite_mask, box2 (the token Image_Pair_crop needs - keep this wired), and new_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.

CategoryApt_Preset/image

Inputs (11)

NameTypeDefaultDescription
layout_modeCOMBO10 options: 左右-中心对齐, 左右-高度对齐, 左右-宽度对齐, 上下-中心对齐, 上下-宽度对齐, 上下-高度对齐, +4
bg_modeCOMBO8 options: crop_image, image, transparent, white, black, red, +2
size_modeCOMBO3 options: auto, 输出宽度, 输出高度
target_sizeINT51264–4096
divider_thicknessINT00–20
image1optIMAGE
mask1optMASK
image2optIMAGE
mask2optMASK
mask1_stackoptMASK_STACK2
mask2_stackoptMASK_STACK2

Outputs (5)

NameTypeDescription
composite_imageIMAGE
composite_maskMASK
box2BOX2
new_img2IMAGE
new_mask2MASK