ComfyUI Node

Image IC

Stitch two images into one canvas for in-context LoRA work

By yichengup·Created 2 years ago·Updated 4 months ago· 47
Image IC
  • first_image
  • second_image
  • first_mask
  • second_mask
  • IMAGE
  • MASK
  • FIRST_MASK
  • SECOND_MASK
  • first_size
  • second_size
reference_edgeimage1_width
combine_modehorizontal
second_image_scale1.0
second_image_positioncenter
final_size1024
background_color#FFFFFF

If you've seen the Flux "in-context" workflows, you know the pattern: put a reference image on the left half of a canvas, leave the right half blank, and let the model outpaint the right side using the left as context. It's how people do one-shot consistent outpainting and partial redraws without a full re-generation - and it's exactly the workflow where two random images need to be glued onto one canvas at a matching scale, with masks that say which half is real. ImageIC is that glue. It's a two-image combination node built specifically for in-context LoRA and Flux Fill+Redux partial redraw pipelines.

How it works

You give it two images, and it stitches them horizontally or vertically onto a shared canvas. The clever part is how they're sized. reference_edge declares which image's edge is the anchor - say image1_width - and the other image is scaled so its corresponding edge matches that dimension, giving you a seamless shared dimension down the seam. second_image_scale fine-tunes the second image on top of that, and second_image_position (top/center/bottom/left/right) places it against the first. final_size then scales the whole combined canvas to a target long-edge length, and background_color fills any leftover canvas.

The node also tracks regions, not just pixels: it outputs a combined MASK plus separate FIRST_MASK and SECOND_MASK (which parts of the canvas belong to each input) and two size tuples for downstream math. Feed those masks to an inpaint/conditioning stack and the model knows exactly what's reference and what's blank to invent.

The inputs that matter

  • first_image / second_image - the two inputs.
  • reference_edge - image1_width, image1_height, image2_width, image2_height; which edge anchors the scale. This is the knob that makes the seam line up.
  • combine_mode - horizontal or vertical.
  • second_image_scale - 0.1–2.0, on top of the anchor matching.
  • second_image_position - top/center/bottom/left/right placement against the first image.
  • final_size - target long edge, 64–8192, step 64.
  • background_color - canvas filler.
  • first_mask / second_mask - optional per-image masks.

Outputs: IMAGE, MASK, FIRST_MASK, SECOND_MASK, first_size, second_size.

Why this node exists

The pack README says it outright: these combination nodes exist to "save the size of Flux iclora and Fill+redux when partial redrawing" - i.e., don't regenerate the whole image, combine the existing part with a blank and let the model only work the blank. The source is a rework of lrzjason/Comfyui-In-Context-Lora-Utils by the pack author, so if you've seen that earlier tool, this is its updated form. For Flux ICLora specifically: reference on the left, masked-blank on the right, outpaint the right side - and the masks this node emits are what make that clean instead of guesswork.

Installing it

Part of ComfyUI-YCNodes. ComfyUI Manager → search ComfyUI-YCNodes → install, or:

cd ComfyUI/custom_nodes
git clone https://github.com/yichengup/ComfyUI-YCNodes

Restart, then look under YCNode/Image. Requires opencv-python (imported as cv2) plus numpy/torch - all in the pack's requirements.txt.

Gotchas

The inputs are single-image oriented: it takes the first frame of each batch tensor, so don't feed it video batches and expect per-frame stitching. The reference_edge behavior means the second image is resampled to match - if you wanted it untouched, set second_image_scale and pick the anchor that least distorts it. And the masks are region masks, not per-pixel alpha of transparency: they say "this pixel belongs to image 1" as a white value, so treat them as selection regions, not blend weights.

CategoryYCNode/Image

Inputs (10)

NameTypeDefaultDescription
first_imageIMAGE
second_imageIMAGE
reference_edgeCOMBOimage1_width4 options: image1_width, image1_height, image2_width, image2_height
combine_modeCOMBOhorizontal2 options: horizontal, vertical
second_image_scaleFLOAT1.00.1–2
second_image_positionCOMBOcenter5 options: top, center, bottom, left, right
final_sizeINT102464–8192
background_colorSTRING#FFFFFF
first_maskoptMASK
second_maskoptMASK

Outputs (6)

NameTypeDescription
IMAGEIMAGE
MASKMASK
FIRST_MASKMASK
SECOND_MASKMASK
first_sizeTUPLE
second_sizeTUPLE