📐 智绘_图片排列
Borders, gaps, spacing and auto layout
- 📸 基准图输入
- 📦 图片批次输入
- 🖼️ 组合图
If ZH_GridImageAssembler is the plain contact sheet, ZH_ImageLayout (📐 智绘_图片排列) is the one that makes it look like you cared. It lays a batch of images out with a real layout engine - direction, fixed columns or rows, per-cell scale modes, spacing, borders, background color - and it can drop a base image in as the layout's anchor. This is the node for before/after comparisons, side-by-side A/B grids, storyboards, and product-grid presentations, where the plain grid's zero-spacing, no-border output just won't cut it.
How it works
The organizing concept is a base-plus-batch layout. Optional 基准图输入 (base image) goes in one spot, and the 图片批次输入 (image batch) tiles around it. The 排列方向 (layout direction) decides the arrangement - 左右 (side by side), 上下 (top/bottom), or the corner-anchored 左上/右上 variants - and the 布局模式 (layout mode) decides how the grid is shaped: 自动 (auto - the pack figures out rows/columns from the batch), 固定列数 (fixed columns), or 固定行数 (fixed rows). There's also a 文件夹路径 (folder path) input that loads images straight from disk instead of a batch socket - pick whichever source suits your flow.
Then the presentation controls, and this is where it beats the plain grid:
缩放模式- 适应 (fit, preserve ratio + pad - the default), 裁剪 (crop, preserve ratio + cut), or 拉伸 (stretch to fill the cell).小图尺寸(thumbnail size, 256 default) - the master cell size the layout works from.边框宽度+边框颜色- outlines around each image (2px black default), plus小图间距(gap between cells, 4px default) and背景颜色(black/white/transparent/custom RGB).基准图尺寸模式- whether the base image defines the layout scale or you set a自定义最长边(custom longest side, 1024 default).
Output is one 组合图 (IMAGE) - the finished presentation sheet.
The inputs that matter
For a first pass you touch four: 排列方向 (start with 左右), 布局模式 (自动 is fine), 缩放模式 (适应 for safe fits), and 小图间距 if the cells feel cramped. The border/background knobs are polish you'll dial in once. Feed it either the batch socket or the folder path - not both on the first run, or you'll be debugging which source won.
Install
Part of the 智绘灵箱 (ComfyUI-ZhiHui) pack:
cd ComfyUI/custom_nodes
git clone https://github.com/zhuyungen/ComfyUI-ZhiHui.git
Restart ComfyUI (or ComfyUI Manager, "智绘灵箱" / "ComfyUI-ZhiHui"). Pillow-only at runtime.
Where people get burned
- The transparent background only matters if your save format supports it. Set 背景颜色 to 透明 and save as JPG and you get black or white, not alpha. Know your output format.
- Custom RGB is a string, not a color picker.
自定义背景RGBtakes"255,255,255"- comma-separated numbers in a text field. Type it wrong and you'll wonder why the color is off. - "自动" layout is a guess, not magic. If the sheet comes out ragged, switch to fixed columns/rows and take control. Auto does what it thinks, which isn't always what you see.
- Two layout nodes in one pack, again.
ZH_GridImageAssembleris the quick grid with a cell-size cap; this is the presentation version. Grab the wrong one and your workflow still runs - it just looks different than you intended.
If your output needs to read as a finished presentation rather than a debug contact sheet, this is the one. It's more knobs than the plain grid, but every knob maps to a visible thing - and that's exactly what you want when the sheet is the deliverable.
Inputs (17)
| Name | Type | Default | Description |
|---|---|---|---|
| 🔢 排列方向 | COMBO | 左右 | 4 options: 左右, 上下, 左上, 右上 |
| 📏 基准图尺寸模式 | COMBO | 2 options: 默认(使用原图尺寸), 自定义最长边 | |
| 📏 自定义最长边 | INT | 102464–8192 | — |
| 🖼️ 布局模式 | COMBO | 自动 | 3 options: 自动, 固定列数, 固定行数 |
| 🔢 固定列数 | INT | 31–20 | — |
| 🔢 固定行数 | INT | 31–20 | — |
| 📐 小图尺寸 | INT | 25664–1024 | — |
| 🎨 缩放模式 | COMBO | 适应(保持比例+填充) | 3 options: 适应(保持比例+填充), 裁剪(保持比例+裁剪), 拉伸(填满格子) |
| 🌈 背景颜色 | COMBO | 4 options: 黑色, 白色, 透明, 自定义 | |
| 🎨 自定义背景RGB | STRING | 255,255,255 | — |
| 📏 边框宽度 | INT | 20–20 | — |
| 🌈 边框颜色 | COMBO | 3 options: 黑色, 白色, 自定义 | |
| 🎨 自定义边框RGB | STRING | 0,0,0 | — |
| 📏 小图间距 | INT | 40–50 | — |
| 📸 基准图输入opt | IMAGE | — | |
| 📦 图片批次输入opt | IMAGE | — | |
| 📁 文件夹路径opt | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| 🖼️ 组合图 | IMAGE | — |