Nodes/comfyui-AGSoft/AGSoft Image Stitch
ComfyUI Node

AGSoft Image Stitch

Stitch 2–4 images into one canvas without the alignment guessing game

By Art-xmaster·Created 12 months ago·Updated a day ago· 23
AGSoft Image Stitch
  • image1
  • image2
  • image3
  • image4
  • IMAGE
  • WIDTH
  • HEIGHT
stitch_moderight
match_image_sizetrue
megapixels0.00
max_width0
max_height0
upscale_methodlanczos
spacing_width0
background_color_presetwhite (#FFFFFF)
multiple_of0
custom_background_color

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 if megapixels is 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_preset and spacing_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.

CategoryAGSoft/Image

Inputs (14)

NameTypeDefaultDescription
image1IMAGEОбязательное первое изображение. От него зависит ориентация сшивания.
stitch_modeCOMBOrightРежим сшивания: • right — справа от первого • down — под первым • left/up — слева/сверху • 2x2 — сетка 2×2 (до 4 изображений) • context_mode — специальный режим: - При 3 изображениях: image1+image2 вертикально, image3 справа. - При 4 изображениях: image1+image2+image3 вертикально, image4 справа.
match_image_sizeBOOLEANtrueЕсли включено — второе и последующие изображения масштабируются ПРОПОРЦИОНАЛЬНО, чтобы соответствовать первому (без искажения).
megapixelsFLOAT0.000–16Целевой размер финального изображения в мегапикселях (0 = без ограничений).
max_widthINT00–8192Максимальная ширина результата (0 = без ограничений). Игнорируется, если megapixels > 0.
max_heightINT00–8192Максимальная высота результата (0 = без ограничений). Игнорируется, если megapixels > 0.
upscale_methodCOMBOlanczosМетод интерполяции при масштабировании. Lanczos даёт наилучшее качество.
spacing_widthINT00–512Расстояние (в пикселях) между изображениями. Заполняется цветом фона.
background_color_presetCOMBOwhite (#FFFFFF)Выберите предустановленный цвет фона. Используется, если custom_background_color пуст.
multiple_ofCOMBO0Привести итоговые размеры изображения к кратности указанному числу. • 0 = отключено • 8 = стандарт для большинства моделей Stable Diffusion • 64 = требуется для некоторых VAE или видео-моделей • 112, 128 = для специфических архитектур Если включено, изображение будет центрировано на холсте, размеры которого кратны выбранному значению.
image2optIMAGEВторое изображение (опционально).
image3optIMAGEТретье изображение (опционально).
image4optIMAGEЧетвёртое изображение (опционально).
custom_background_coloroptSTRINGПроизвольный цвет фона в формате #RRGGBB. Если указан — переопределяет background_color_preset.

Outputs (3)

NameTypeDescription
IMAGEIMAGE
WIDTHINT
HEIGHTINT