Image Stitch (RMBG) 🖼️
Join up to four images into one, Kontext-ready
- image1
- background_color
- image2
- image3
- image4
- IMAGE
- WIDTH
- HEIGHT
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) plusimage2,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. Pickkontext_modewhen 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(defaultlanczos) - the resampler used when matching sizes.lanczosis the sharp default; drop tobilinearorareaif you want softer.spacing_widthandbackground_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, thenpip 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.
Inputs (12)
| Name | Type | Default | Description |
|---|---|---|---|
| image1 | IMAGE | — | |
| stitch_mode | COMBO | right | Mode for stitching images together |
| match_image_size | BOOLEAN | true | If True, resize image2 to match image1's aspect ratio |
| megapixels | FLOAT | 0.000–16 | Target megapixels for final output (0 = no limit, overrides max_width/max_height) |
| max_width | INT | 00–16384 | Maximum width of output image (0 = no limit, ignored if megapixels > 0) |
| max_height | INT | 00–16384 | Maximum height of output image (0 = no limit, ignored if megapixels > 0) |
| upscale_method | COMBO | lanczos | Upscaling method for all resize operations |
| spacing_width | INT | 00–512 | Width of spacing between images |
| background_color | COLORCODE | #FFFFFF | Color for spacing between images and padding background |
| image2opt | IMAGE | — | |
| image3opt | IMAGE | — | |
| image4opt | IMAGE | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |
| WIDTH | INT | — |
| HEIGHT | INT | — |