Nodes/Soda Storyboard/切格 · Crop Panel
ComfyUI Node

切格 · Crop Panel

Cut One Panel Out of a Finished Page — and Keep the Receipt

By cOkieeman·Created 3 days ago·Updated a day ago· 5
切格 · Crop Panel
  • image
  • panel
  • mask
  • panel_prompt
  • panel_box
◄page_info►
◄panel1►
◄resize_to_1024true►

Cropping a rectangle out of an image is a one-line operation, so a dedicated node for it looks redundant until you try to put the result back. The hard part isn't the crop, it's knowing where the crop came from after you've upscaled it, redrew it, and handed it through four nodes. SodaCropPanel solves the boring part and then hands you the receipt: a panel_box string that SodaPastePanel later uses to slot your redrawn art back into the page at the right place, at the right size, through the panel's actual edge shape.

What it does under the hood

You give it the finished page and a panel selector. It looks up that panel's geometry from page_info, crops to the panel's bounding box, and builds a mask from the panel's shape - not its bounding box. For a rectangular panel those are the same thing; for a slanted panel the mask has the diagonal edge, which is why the mask is useful for masked edits near a border.

If resize_to_1024 is on (it is by default), the crop is scaled so its long edge lands at 1024 and each dimension is rounded to a multiple of 16. That's not cosmetic: latents work in multiples of 16, so anything else gets silently padded or trimmed. The resize uses LANCZOS for the image and nearest-neighbour for the mask, which is what you want - you don't want a blurred mask edge.

It also compiles panel_prompt, the single-panel prompt with the pack's fixed restrictions baked on: no frame, no gutter, no text, no speech bubble. That's deliberate. Cropping one panel means the model shouldn't be told about the whole page's layout, and it definitely shouldn't be invited to draw the panel border again or invent lettering over the art.

The four outputs and where they go

panel is the crop - feed it to your img2img or inpaint branch after an upscale. The standard recipe in the pack's own workflow is: upscale to a 1024 long edge, sample at roughly 0.45 denoise, then paste the result back.

mask is the panel-shaped mask at crop size, ready for inpaint conditioning.

panel_prompt goes into a text encode. Note that the pack compiles it for you and appends the restrictions; don't prepend the full-page layout yourself or you've undone the point.

panel_box is the one nobody expects to need. It's a JSON blob carrying the crop box, the original size, the crop size, the scale factors, the page canvas size, the panel id and the page_info snapshot. SodaPastePanel refuses to work without it, and it validates it: a version mismatch, a canvas-size mismatch, or a box that no longer matches the page geometry all raise instead of silently pasting into the void. That strictness is a feature - it's what stops you from pasting a panel from page three onto page four.

One caveat worth knowing if you batch: the node processes every image in the image batch, but panel_prompt and panel_box come from the first image only. Batch-cropping the same panel across variations is fine; expecting per-image boxes is not.

Install

This ships in ComfyUI-Soda-Storyboard and needs the separate soda-storyboard core library - no cores, no node.

cd ComfyUI/custom_nodes
git clone https://github.com/cOkieeman/ComfyUI-Soda-Storyboard
cd ComfyUI-Soda-Storyboard && python -m pip install --upgrade soda-storyboard

Manager: search Soda Storyboard, or comfy node install comfyui-soda-storyboard. Restart. Windows portable users should install with the embedded Python's pip (.\python_embeded\python.exe -m pip install -r ...\requirements.txt), and if you hit BackendUnavailable: Cannot import 'uv_build' you've installed the git source dependency instead of the wheel - the requirements file fixes it.

Common issues

The panel widget is a string. Type 1 for the first panel in reading order, or the panel id. Pages read right-to-left list their panels in that order, so a manga page's "panel 1" is the rightmost one - that surprises people coming from left-to-right comics.

"找不到格子" means your selector doesn't exist on this page. "请先导入分镜包" means nothing is uploaded yet. Neither is a crash in the node so much as a mirror of what the loader screen was already telling you.

The real trap is upstream: if you crop from a 1024×1536 page and then try to paste into a 2048×3072 version of the same page, SodaPastePanel will tell you the page size doesn't match what you cropped from. That's correct behaviour - re-crop from the version you intend to paste into, or do your compositing before the upscale.

CategorySoda Storyboard

Inputs (4)

NameTypeDefaultDescription
imageIMAGE—
page_infoSTRING—
panelSTRING1—
resize_to_1024BOOLEANtrue—

Outputs (4)

NameTypeDescription
panelIMAGE—
maskMASK—
panel_promptSTRING—
panel_boxSTRING—