ComfyUI Node

GridImageSplitter

The grid splitter that actually snaps to the gutter lines

By stormcenter·Created 2 years ago·Updated 2 years ago· 47
GridImageSplitter
  • image
  • IMAGE
  • IMAGE
rows2
cols3
row_split_method
col_split_method

You've got a comic page, a contact sheet, or a screenshot that's secretly a grid, and you want each panel as its own image. Doing that with one crop node per cell is misery, and it's a problem people actually ask about - there are r/comfyui threads on exactly "how do I extract every panel of a comic page." GridImageSplitter, from the stormcenter/ComfyUI-AutoSplitGridImage pack, does the whole thing in one node. The unusual part: it doesn't just chop on a grid. It looks for the seams.

What it does

It takes a single image, cuts it into rows × cols cells, and gives you two outputs: a preview with green cut lines drawn over the original, and a batch tensor of the cells themselves. That green-line preview is the unsung hero - glance at it before anything consumes the cells, and you'll never silently ruin a batch because a cut landed on someone's face.

The real story is edge_detection. Set either axis to it and the node runs Canny edge detection (thresholds 50/150 in the source), sums edge density along that axis, smooths it, and picks the quietest spot near where each cut should be. Then it snaps each cut to the actual border of the cell using HSV and LAB color checks, so a black or white gutter doesn't end up glued to your panel. Each cell gets its external black/white borders trimmed off, and finally every cell is resized with LANCZOS4 to fit the largest cell - aspect preserved, centered on a black canvas - and stacked into one batch. So the cuts hug the gutters and the cells come out clean and uniform, which is exactly what downstream batch processing wants.

The inputs that matter

  • image - the image to split (IMAGE).
  • rows / cols - 1 to 10, default 2 × 3. Rows=2 means one horizontal cut → two rows. Remember it's rows × cols, and you can't go above 10 either way.
  • row_split_method / col_split_method - uniform or edge_detection, set independently. Mixing is where this shines: uniform columns for a sprite sheet, edge detection rows for a comic page.

Outputs are two IMAGE tensors: the preview with green lines, and the stacked cells (batch dimension = rows × cols). Feed the batch into anything batch-aware - a Save Image that handles batches, or process each cell through img2img/upscale by indexing the batch.

Install

ComfyUI Manager (search "AutoSplitGridImage") or the manual way:

cd ComfyUI/custom_nodes
git clone https://github.com/stormcenter/ComfyUI-AutoSplitGridImage

Then restart ComfyUI. Dependencies are light - numpy, pillow, opencv-python, torch. No model downloads, no huge install. The one wrinkle: it wants opencv-python, and if ComfyUI already pulled in opencv-python-headless, the two can fight over the cv2 module. It usually resolves itself, but if you get cv2 import errors right after installing, that's the culprit.

Where people get burned

  • It only reads the first image of an input batch - the source grabs image[0]. Don't feed it a batch expecting batch splitting.
  • Edge detection is only as good as your gutters. Busy art with no clean borders gets snapped to random minima. Always check the preview output before trusting the cells.
  • The black letterbox padding is baked in. Every cell is centered on a black canvas to equalize size, so feeding cells straight into img2img gives you black bars. Crop or mask them if that matters.
  • Cells are downscaled to the smallest one. Don't expect full-resolution panels out of a mixed-size page.

The cells can also come out odd-sized after all that trimming - that's exactly what EvenImageResizer, the pack's other node, is for. Stick it before a VAEEncode and you're clear.

Categoryimage/processing

Inputs (5)

NameTypeDefaultDescription
imageIMAGE
rowsINT21–10
colsINT31–10
row_split_methodCOMBO2 options: uniform, edge_detection
col_split_methodCOMBO2 options: uniform, edge_detection

Outputs (2)

NameTypeDescription
IMAGEIMAGE
IMAGEIMAGE