Nodes/ComfyUI-ZML-Image/ZML_图像拆分宫格
ComfyUI Node

ZML_图像拆分宫格

Cut one image into a grid of cells

By zml-w·Created about a year ago·Updated 2 months ago· 218
ZML_图像拆分宫格
  • 图像
  • 宫格图像批次
行数2
列数2
水平间距0
垂直间距0
保持原尺寸false

ComfyUI has a hundred ways to do this, but most of them assume you want equal slices and don't give you much control. ZML_ImageGridSplit (ZML_图像拆分宫格, "split into a grid") is the pack's take on cutting one image into rows×columns of cells, and its two extra toggles - cell spacing and keep-original-size - are the reason it's worth a look over a bare slice.

It's from ComfyUI-ZML-Image, zml-w's 160+ node utility pack, added in an April update. It sits in the plain image subcategory and does pure tensor slicing - no OpenCV, no models, no heavy machinery.

How it works

The node takes your image and a 行数 (rows) / 列数 (columns) pair, then slices it into that many rectangular cells, left-to-right, top-to-bottom, and concatenates them into a single output batch. Two knobs change the geometry:

  • 水平间距 / 垂直间距 (horizontal/vertical spacing) - carve out a gap of N pixels between cells. Instead of touching edges, each cell keeps a small margin. Handy when you want visible seams in the output, like slicing a spritesheet into clearly separated tiles.
  • 保持原尺寸 (keep original size) - when on, each cell keeps the full canvas: the cell sits in its correct position and everything outside it is black. When off (default), cells are tightly cropped to their own size.

The output is a single 宫格图像批次 (grid image batch) - an IMAGE with batch dimension = rows×columns. That's the thing to remember: it's a batch, not five separate wires. If you need individual images, grab them with a batch-to-list or get-item node (the pack ships ZML_Batch_To_List and ZML_Get_Item_From_List for exactly this), or feed the batch straight into a node that accepts batches - which is where this shines.

What it's actually good for

  • Character sheets / reference grids - split a multi-view sheet into per-view images you can feed an img2img or detailer per panel.
  • Tiled inpainting - slice a big image into tiles, process each independently, stitch back with a merge node. The spacing parameter even lets you add overlap margins if your inpaint needs context.
  • Any "process each region separately" workflow, from contact sheets to sprite slicing.

Installing it

Standard pack install - you get the whole family:

cd ComfyUI/custom_nodes
git clone https://github.com/zml-w/ComfyUI-ZML-Image

restart ComfyUI, or ComfyUI Manager → search "ComfyUI-ZML-Image" → install. The pack's requirements list is heavy (OpenCV, scipy, ultralytics) but this node uses nothing beyond core ComfyUI. No model files needed.

Where people get caught

If you wire the batch output into a node that only accepts a single image, you'll get an error or a silent first-frame-only result - it's genuinely a batch. Convert it with the pack's list/batch helpers first. And note the cells are cut, not resized: if the image doesn't divide evenly, the last row or column is simply a bit smaller. Set 保持原尺寸 on if you need uniform full-canvas cells regardless.

When you'd actually reach for it

This is a "shapes" utility you'll use more than you expect once it's installed - mostly because the batch output plays so well with batch-processing nodes. If you only slice one image into equal halves occasionally, the stock nodes are fine. If you're building tiled pipelines or processing sheets panel-by-panel, the spacing and keep-size options earn their keep.

Categoryimage/ZML_图像/图像

Inputs (6)

NameTypeDefaultDescription
图像IMAGE输入要拆分的图像
行数INT21–32垂直方向拆分的行数
列数INT21–32水平方向拆分的列数
水平间距INT00–1024宫格之间的水平间距(像素)
垂直间距INT00–1024宫格之间的垂直间距(像素)
保持原尺寸BOOLEANfalse是否保持每个宫格为原图尺寸,而非裁剪后的尺寸

Outputs (1)

NameTypeDescription
宫格图像批次IMAGE