AGSoft Image Stitch
Stitch 2–4 images into one canvas without the alignment guessing game
- image1
- image2
- image3
- image4
- IMAGE
- WIDTH
- HEIGHT
AGSoft Image Stitch is the pack's answer to "I have two or three images that belong side by side and I'd rather not build that with a pile of Pad + Concat nodes." It takes up to four images and lays them into a single canvas in a pattern you pick - right, down, left, up, a 2×2 grid, or a "context" layout. It also matches sizes for you, so the result actually looks stitched instead of slapped together.
The genuinely useful part is match_image_size. With it on (the default), the second and subsequent images get scaled proportionally to line up with the first - no distortion, no weird aspect-ratio stretch. That's the difference between a usable reference sheet and a mess you have to fix by hand.
How it works
Under the hood it's a torch.cat along the width or height axis, with a few bits of prep. It makes sure the input batches match (repeating the last frame if needed), optionally rescales the incoming images so their edges match the first image's dimension, optionally inserts a colored gap (spacing_width), and then concatenates. All four images are optional beyond image1; missing slots become blank panels in grid mode.
The stitch_mode dropdown is where the layout lives:
- right / down / left / up - the obvious compass points; the second image goes where you say.
- 2x2 - a grid of up to four images.
- context_mode - the interesting one. With 3 images, image1 + image2 stack vertically and image3 goes on the right; with 4, image1+2+3 stack vertically and image4 sits on the right. It's purpose-built for building a "main panel + context strip" reference layout.
Then there are the guardrails that keep the result feedable:
megapixels- caps the final canvas size (0 = no limit). Set it and the whole composition gets scaled to fit a target like 2 MP.max_width/max_height- alternative caps on the result dimensions. Ignored ifmegapixelsis set.multiple_of- snaps the output to a multiple (8, 64, etc.) so the stitched canvas is sampler-safe. The tooltip even walks through which value different model families want.upscale_method- interpolation for the size-matching (lanczos default).background_color_presetandspacing_width- the gap between panels and its fill color, for readable reference sheets.
Outputs: image (IMAGE). That's it - one clean composited result.
Installation
From comfyui-AGSoft:
cd ComfyUI/custom_nodes
git clone https://github.com/Art-xmaster/comfyui-AGSoft.git
# restart ComfyUI
Or ComfyUI Manager → search "comfyui-AGSoft". numpy + opencv, no models.
Where people get burned
The main gotcha is expecting pixel-exact sizing without match_image_size. Turn it off and you're back to "the two halves have different heights" territory. Keep it on and the node rescales, which is what you usually want for reference sheets - but if you're stitching images that must keep exact pixel dimensions (say, outpainting tiles), you'll want match_image_size off and matching resolutions upstream. Also note this node is for stitching separate images; the pack's Image Concatenate From Batch is the one for turning a whole batch into a grid in one step.
Inputs (14)
| Name | Type | Default | Description |
|---|---|---|---|
| image1 | IMAGE | Обязательное первое изображение. От него зависит ориентация сшивания. | |
| stitch_mode | COMBO | right | Режим сшивания: • right — справа от первого • down — под первым • left/up — слева/сверху • 2x2 — сетка 2×2 (до 4 изображений) • context_mode — специальный режим: - При 3 изображениях: image1+image2 вертикально, image3 справа. - При 4 изображениях: image1+image2+image3 вертикально, image4 справа. |
| match_image_size | BOOLEAN | true | Если включено — второе и последующие изображения масштабируются ПРОПОРЦИОНАЛЬНО, чтобы соответствовать первому (без искажения). |
| megapixels | FLOAT | 0.000–16 | Целевой размер финального изображения в мегапикселях (0 = без ограничений). |
| max_width | INT | 00–8192 | Максимальная ширина результата (0 = без ограничений). Игнорируется, если megapixels > 0. |
| max_height | INT | 00–8192 | Максимальная высота результата (0 = без ограничений). Игнорируется, если megapixels > 0. |
| upscale_method | COMBO | lanczos | Метод интерполяции при масштабировании. Lanczos даёт наилучшее качество. |
| spacing_width | INT | 00–512 | Расстояние (в пикселях) между изображениями. Заполняется цветом фона. |
| background_color_preset | COMBO | white (#FFFFFF) | Выберите предустановленный цвет фона. Используется, если custom_background_color пуст. |
| multiple_of | COMBO | 0 | Привести итоговые размеры изображения к кратности указанному числу. • 0 = отключено • 8 = стандарт для большинства моделей Stable Diffusion • 64 = требуется для некоторых VAE или видео-моделей • 112, 128 = для специфических архитектур Если включено, изображение будет центрировано на холсте, размеры которого кратны выбранному значению. |
| image2opt | IMAGE | Второе изображение (опционально). | |
| image3opt | IMAGE | Третье изображение (опционально). | |
| image4opt | IMAGE | Четвёртое изображение (опционально). | |
| custom_background_coloropt | STRING | Произвольный цвет фона в формате #RRGGBB. Если указан — переопределяет background_color_preset. |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |
| WIDTH | INT | — |
| HEIGHT | INT | — |