Nodes/ComfyUI_LLM_Banana/🍌 Gemini Banana 图片拼接 (最多30张)
ComfyUI Node

🍌 Gemini Banana 图片拼接 (最多30张)

Stack 30 images into one numbered grid so Gemini can find them

By xuchenxu168·Created 12 months ago·Updated 9 months ago· 46
🍌 Gemini Banana 图片拼接 (最多30张)
  • image1
  • image2
  • image3
  • image4
  • image5
  • image6
  • image7
  • image8
  • image9
  • image10
  • image11
  • image12
  • image13
  • image14
  • image15
  • image16
  • image17
  • image18
  • image19
  • image20
  • image21
  • image22
  • image23
  • image24
  • image25
  • image26
  • image27
  • image28
  • image29
  • image30
  • collage_image
  • position_guide
max_cell_size512
resize_modekeep_aspect_ratio
add_numberstrue
number_size48
number_positiontop-left
background_colorwhite

Here's a node with a twist: it's in an API-heavy pack, but it's pure local image processing. No network, no key, no model. What it does is take up to 30 images and stitch them into a single numbered grid - cell 1, cell 2, cell 3 - and hand you a text guide saying which number sits where. Sounds trivial until you've tried pointing a Gemini/Nano-Banana image model at five separate reference images and asking it to "edit the second one." Multi-image models have a much easier time when they can say "change cell 7" than when they're guessing which of your five photos you meant.

That's the whole design intent: the pack's multi-image edit nodes (KenChenLLMGeminiBananaMultiImageEditNode etc.) work far better with a numbered collage as input, because the position guide gives the model a stable reference frame. Use this node as the front of that workflow.

How it works

It converts each input tensor to PIL, computes a grid layout (2×1 for two images, 2×2 up to four, 3×2, 3×3, … 6×5 for 26–30), scales each image into its cell, optionally draws a big number on top, and returns the composite plus a position_guide string like "1: top-left, 2: top-right…" written in a way the model can read. The layout always grows toward a square-ish shape, which models recognize better than a long strip.

The inputs that matter

  • image1image30 - the optional IMAGE wires. Whatever you don't wire simply isn't in the grid.
  • max_cell_size - each cell's maximum edge (default 512, range 256–1024). Bigger cells mean a higher-res collage but a heavier request to the API.
  • resize_mode - keep_aspect_ratio (default, scales to fit within the cell), fit_to_cell (fills the cell, may distort), original_size (no upscaling of small images).
  • add_numbers - on by default, and you want it on: the numbers are what let the model target cells.
  • number_size, number_position, background_color - cosmetic; white/black/gray background fills the leftover space.

Outputs: collage_image (IMAGE) and position_guide (STRING). Feed both into a multi-image edit node - the collage into the image input, the guide into the prompt or a text input so the model knows the layout.

Install

ComfyUI Manager (search ComfyUI_LLM_Banana) or:

cd ComfyUI/custom_nodes
git clone https://github.com/xuchenxu168/ComfyUI_LLM_Banana
cd ComfyUI_LLM_Banana
pip install -r requirements.txt

It only needs Pillow/numpy, which the pack already pulls in. Restart, done.

Gotchas

Two practical ones. First, grid cell count and aspect ratio can make your subjects tiny - with 20 images at 512px cells you're effectively showing the model thumbnails, and detail-heavy edits will suffer; raise max_cell_size for important work (it'll cost more tokens/bandwidth). Second, the position_guide is a string you actually have to wire into the edit node for the numbers to mean anything to the model - forgetting it defeats the whole point.

CategoryKen-Chen/LLM-Nano-Banana

Inputs (36)

NameTypeDefaultDescription
max_cell_sizeINT512256–1024单元格最大尺寸(图片会等比缩放到此尺寸内,保持长宽比)
resize_modeCOMBOkeep_aspect_ratio缩放模式:keep_aspect_ratio=保持长宽比,fit_to_cell=填满单元格(可能变形),original_size=保持原始尺寸(小图不放大)
add_numbersBOOLEANtrue是否在每张图片上添加序号标识
number_sizeINT4824–128序号文字大小
number_positionCOMBOtop-left序号位置
background_colorCOMBOwhite背景颜色(用于填充空白区域)
image1optIMAGE
image2optIMAGE
image3optIMAGE
image4optIMAGE
image5optIMAGE
image6optIMAGE
image7optIMAGE
image8optIMAGE
image9optIMAGE
image10optIMAGE
image11optIMAGE
image12optIMAGE
image13optIMAGE
image14optIMAGE
image15optIMAGE
image16optIMAGE
image17optIMAGE
image18optIMAGE
image19optIMAGE
image20optIMAGE
image21optIMAGE
image22optIMAGE
image23optIMAGE
image24optIMAGE
image25optIMAGE
image26optIMAGE
image27optIMAGE
image28optIMAGE
image29optIMAGE
image30optIMAGE

Outputs (2)

NameTypeDescription
collage_imageIMAGE
position_guideSTRING