Nodes/ComfyUI-RMBG/Image Stitch (RMBG) 🖼️
ComfyUI Node Runs on cloud

Image Stitch (RMBG) 🖼️

Join up to four images into one, Kontext-ready

By 1038lab·Created 2 years ago·Updated 8 days ago· 2,051
Image Stitch (RMBG) 🖼️
  • image1
  • background_color
  • image2
  • image3
  • image4
  • IMAGE
  • WIDTH
  • HEIGHT
stitch_moderight
match_image_sizetrue
megapixels0.00
max_width0
max_height0
upscale_methodlanczos
spacing_width0

Glue images together side by side, top to bottom, or into a 2x2 grid. That's the basic job, and it's useful on its own for before/after comparisons and contact sheets. But the reason this node got a redesign and a dedicated kontext_mode is the editing-model workflow: Flux Kontext and friends often want a reference image and a working image concatenated into one canvas, and stitching them correctly is fiddlier than it looks.

The RMBG author rebuilt this node to be compatible with ComfyUI's native stitching behavior, so it plays nicely in modern graphs instead of fighting them. If you've been hand-rolling image concatenation with generic math nodes, this replaces that with one node that handles sizing, spacing, and resampling for you.

How it works

You give it up to four images and a direction. It resizes them to line up (optionally), lays them out, and returns one combined image plus its dimensions. The layout modes cover the common cases: right, down, left, up for linear strips, 2x2 for a grid, and kontext_mode for the reference-editing layout.

The inputs that matter

  • image1 (required) plus image2, image3, image4 (optional) - the images to join. Connect two for a simple pair, up to four for a grid.
  • stitch_mode - the layout: right / down / left / up / 2x2 / kontext_mode. Pick kontext_mode when you're feeding a Kontext editing model; pick a direction for plain comparisons.
  • match_image_size (default on) - resize inputs so they line up cleanly along the seam. Leave it on unless you specifically want raw, mismatched sizes.
  • upscale_method (default lanczos) - the resampler used when matching sizes. lanczos is the sharp default; drop to bilinear or area if you want softer.
  • spacing_width and background_color - put a gap of a chosen color between images. Zero spacing butts them flush; a few pixels of white makes a cleaner comparison sheet.

megapixels, max_width, and max_height cap the output size so a stitch of large images doesn't blow up into something unwieldy - leave them at 0 for no cap.

Outputs are IMAGE, WIDTH, and HEIGHT.

How to install it

  • ComfyUI Manager: search Comfyui-RMBG, install, restart.
  • Manual: cd ComfyUI/custom_nodes && git clone https://github.com/1038lab/ComfyUI-RMBG, then pip install -r requirements.txt, and restart.

Pure image op, no model - instant.

Common issues

If the seam looks off - one image squashed or stretched - that's match_image_size doing its job on inputs with very different aspect ratios. Either pre-crop the inputs to compatible shapes, or accept the resize. If your images come out blurry after stitching, you're probably hitting a max_width/max_height/megapixels cap that downscaled the result; set those to 0 to disable. And if you're using kontext_mode but the downstream model isn't doing what you expect, double-check the model actually is a Kontext-family editor - kontext_mode just arranges the canvas the way those models want; it can't make a non-Kontext model read a reference.

Category🧪AILab/🖼️IMAGE

Inputs (12)

NameTypeDefaultDescription
image1IMAGE
stitch_modeCOMBOrightMode for stitching images together
match_image_sizeBOOLEANtrueIf True, resize image2 to match image1's aspect ratio
megapixelsFLOAT0.000–16Target megapixels for final output (0 = no limit, overrides max_width/max_height)
max_widthINT00–16384Maximum width of output image (0 = no limit, ignored if megapixels > 0)
max_heightINT00–16384Maximum height of output image (0 = no limit, ignored if megapixels > 0)
upscale_methodCOMBOlanczosUpscaling method for all resize operations
spacing_widthINT00–512Width of spacing between images
background_colorCOLORCODE#FFFFFFColor for spacing between images and padding background
image2optIMAGE
image3optIMAGE
image4optIMAGE

Outputs (3)

NameTypeDescription
IMAGEIMAGE
WIDTHINT
HEIGHTINT