MOSS Storyboard Crop
Slice a grid into panels without losing a pixel
- image
- panels
- preview
- report
- index
Grid-slicing feels too dumb to need a node until you have sixteen panels and one of them is 683 pixels wide while its neighbours are 682 - then a batch stack throws Sizes of tensors must match and you lose an evening to arithmetic. This node exists because that arithmetic already went wrong once: an earlier implementation rounded each cell independently and produced exactly the 683/682/683 split.
What it does
Hand it a grid, it hands back the cells. The interesting part is how it decides where they are.
With spec wired in, it reconstructs the exact layout the grid was generated from - same canvas, cell size, gutter and margins - and cuts on those coordinates. Pixel-identical to what the Sampler produced. Row-major, left to right then top to bottom, matching the Sampler's panels output and your [PANEL n] order.
Without spec, it divides the image by columns × rows and demands an exact division, erroring rather than handing you a cell that's one pixel off. Right call: a grid sliced approximately produces panels that don't stack, and that failure surfaces three nodes later.
What "without spec" means in the code is zero gutter and zero margin, straight equal division - great for a borderless contact sheet, wrong for a grid you generated with 8px seams, where each panel picks up a sliver of white. Know the geometry? Wire the spec.
The inputs that matter
image is the grid - the Sampler's grid output, a VAEDecode, or a loaded file.
index is the one people miss. It defaults to -1, meaning "output every panel, as always." Set it to a 0-based panel number and you get only that panel out of panels, plus the number forwarded on the index output. Wire that into a Paste node and you never type a panel number again, and you can't mistype one.
target_aspect defaults to keep, which is what you want: the cell's own aspect, zero resampling. The other options centre-crop to a chosen ratio, non-uniformly. The tooltip says 慎用 and means it.
resize_edge at 0 keeps native size; above 0 it scales each panel's long edge - a convenience, not an upscale.
shave insets each panel by N pixels on all sides, for eating border overflow. Leave it 0 - the Sampler re-draws seams inside the gutter - and if you do use it, remember the number, because Paste needs the same one.
Outputs: panels (a batch - one image per panel, or exactly one if you set index), preview, report (how many panels, their coordinates, and which row and column an indexed panel is), and index.
preview only does anything if you flip show_guides on - then cut lines are drawn in red for eyeballing alignment. Off, it's the input passed through, so don't wire it expecting markup.
Install
Manager: search MOSS Storyboard. Manual:
cd ComfyUI/custom_nodes
git clone https://github.com/ZenHG/ComfyUI-MOSS-Storyboard
Restart and confirm the [MOSS SB] v0.2.2 startup line. This pack installs no extra pip packages - torch and comfy* come from the host, and requirements.txt is empty on purpose so Manager skips pip entirely.
The host floor of ComfyUI ≥ 0.42.0 applies to the pack (that's where the moss_image clip type landed). This node is pure tensor slicing, but you'll run it in a graph that does load models: moss_image_sft_bf16.safetensors in models/unet/, qwen3.5_9b_int8_convrot.safetensors in models/clip/, flux2-vae.safetensors in models/vae/.
Where people get burned
It refuses to cut your image. Either the dimensions don't divide by columns × rows, or the image size doesn't match the spec's layout. Both messages say which. Slicing a grid you didn't generate here? Crop or resize the grid to clean multiples first, or build a spec that matches it.
Panels come out with a white rim. You're on the no-spec path against a bordered grid - equal division has no concept of gutter, so each cell gets a share of the seam. Wire the spec.
Panel numbers don't line up with your script. With the spec they will - same geometry, same row-major order. Off-by-one errors come from hand-typing indices; use the index output.
The batch downstream chokes. panels is a batch. If the next node wants one image, set index or split the batch.
Inputs (10)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | 【接线】整张宫格图(KSampler→VAEDecode 的结果)。 | |
| target_aspect | COMBO | keep | 【填什么】keep = 保持单格原比例(推荐,零重采样)。 选具体比例会做中心裁切,非等比,慎用。 |
| padding_mode | COMBO | crop | 【填什么】crop = 中心裁掉多余边;pad = 补黑边(不丢画面)。 |
| resize_edge | INT | 00–4096 | 【可留 0】0 = 保持原尺寸(推荐)。>0 时把每格长边缩放到该值。 |
| shave | INT | 00–64 | 【可留 0】每格四边内缩像素,用来吃掉溢出的缝。 |
| specopt | STRING | 【接线】接 MossStoryboardLayout/Sampler 的 spec,裁切位置才与生成时完全一致。 | |
| columnsopt | INT | 00–12 | 【未接 spec 时必填】列数。填 0 且无 spec 会报错,不会瞎猜。 |
| rowsopt | INT | 00–12 | 【未接 spec 时必填】行数。 |
| show_guidesopt | BOOLEAN | false | 【调试】在 preview 输出上把裁切线画成红色,用来目检对齐。 |
| indexopt | INT | -1-1–143 | 【可留 -1】-1 = 输出全部格子(默认,行为不变)。 填 0 起的格子号 = 只输出那一格,并把格号送到第 4 个输出 index 上。 接给 MossStoryboardPaste 就不用手打格号,不会错位。 |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| panels | IMAGE | — |
| preview | IMAGE | — |
| report | STRING | — |
| index | INT | — |