🍌 Gemini Banana 图片拼接 (最多30张)
Stack 30 images into one numbered grid so Gemini can find them
- 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
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
image1…image30- 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.
Inputs (36)
| Name | Type | Default | Description |
|---|---|---|---|
| max_cell_size | INT | 512256–1024 | 单元格最大尺寸(图片会等比缩放到此尺寸内,保持长宽比) |
| resize_mode | COMBO | keep_aspect_ratio | 缩放模式:keep_aspect_ratio=保持长宽比,fit_to_cell=填满单元格(可能变形),original_size=保持原始尺寸(小图不放大) |
| add_numbers | BOOLEAN | true | 是否在每张图片上添加序号标识 |
| number_size | INT | 4824–128 | 序号文字大小 |
| number_position | COMBO | top-left | 序号位置 |
| background_color | COMBO | white | 背景颜色(用于填充空白区域) |
| image1opt | IMAGE | — | |
| image2opt | IMAGE | — | |
| image3opt | IMAGE | — | |
| image4opt | IMAGE | — | |
| image5opt | IMAGE | — | |
| image6opt | IMAGE | — | |
| image7opt | IMAGE | — | |
| image8opt | IMAGE | — | |
| image9opt | IMAGE | — | |
| image10opt | IMAGE | — | |
| image11opt | IMAGE | — | |
| image12opt | IMAGE | — | |
| image13opt | IMAGE | — | |
| image14opt | IMAGE | — | |
| image15opt | IMAGE | — | |
| image16opt | IMAGE | — | |
| image17opt | IMAGE | — | |
| image18opt | IMAGE | — | |
| image19opt | IMAGE | — | |
| image20opt | IMAGE | — | |
| image21opt | IMAGE | — | |
| image22opt | IMAGE | — | |
| image23opt | IMAGE | — | |
| image24opt | IMAGE | — | |
| image25opt | IMAGE | — | |
| image26opt | IMAGE | — | |
| image27opt | IMAGE | — | |
| image28opt | IMAGE | — | |
| image29opt | IMAGE | — | |
| image30opt | IMAGE | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| collage_image | IMAGE | — |
| position_guide | STRING | — |