Nodes/ComfyUI-ZhiHui/📐 智绘_图片排列
ComfyUI Node

📐 智绘_图片排列

Borders, gaps, spacing and auto layout

By zhuyungen·Created 8 months ago·Updated 4 months ago· 0
📐 智绘_图片排列
  • 📸 基准图输入
  • 📦 图片批次输入
  • 🖼️ 组合图
◄🔢 排列方向左右►
◄📏 基准图尺寸模式▾►
◄📏 自定义最长边1024►
◄🖼️ 布局模式自动►
◄🔢 固定列数3►
◄🔢 固定行数3►
◄📐 小图尺寸256►
◄🎨 缩放模式适应(保持比例+填充)►
◄🌈 背景颜色▾►
◄🎨 自定义背景RGB255,255,255►
◄📏 边框宽度2►
◄🌈 边框颜色▾►
◄🎨 自定义边框RGB0,0,0►
◄📏 小图间距4►
◄📁 文件夹路径►

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. 自定义背景RGB takes "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_GridImageAssembler is 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.

Category智绘灵箱

Inputs (17)

NameTypeDefaultDescription
🔢 排列方向COMBO左右4 options: 左右, 上下, 左上, 右上
📏 基准图尺寸模式COMBO2 options: 默认(使用原图尺寸), 自定义最长边
📏 自定义最长边INT102464–8192—
🖼️ 布局模式COMBO自动3 options: 自动, 固定列数, 固定行数
🔢 固定列数INT31–20—
🔢 固定行数INT31–20—
📐 小图尺寸INT25664–1024—
🎨 缩放模式COMBO适应(保持比例+填充)3 options: 适应(保持比例+填充), 裁剪(保持比例+裁剪), 拉伸(填满格子)
🌈 背景颜色COMBO4 options: 黑色, 白色, 透明, 自定义
🎨 自定义背景RGBSTRING255,255,255—
📏 边框宽度INT20–20—
🌈 边框颜色COMBO3 options: 黑色, 白色, 自定义
🎨 自定义边框RGBSTRING0,0,0—
📏 小图间距INT40–50—
📸 基准图输入optIMAGE—
📦 图片批次输入optIMAGE—
📁 文件夹路径optSTRING—

Outputs (1)

NameTypeDescription
🖼️ 组合图IMAGE—