Nodes/RUI-Nodes/素材拆分 / Sprite Splitter
ComfyUI Node

素材拆分 / Sprite Splitter

Slice a sprite sheet into separate assets, automatically

By rui40000·Created 3 years ago·Updated 13 days ago· 17
素材拆分 / Sprite Splitter
  • 图像
  • 图像列表
最小面积过滤(像素数)100
裁剪边距2
排序方式从左到右-从上到下
seed0

Sprite Splitter is the node that turns one crowded sheet of game art into a list of individual assets. You feed it a sheet with multiple icons, characters, or elements, and it detects each separate element, crops it to its own box, and outputs a list of images - one per element. For anyone working with game asset sheets, icon sprites, or "dump all the art on one canvas" generation workflows, this saves the tedious manual crop-and-export grind.

Here's the thing you need to know before you use it, and it's the difference between "this works" and "why did it give me one giant image": the splitter works on the alpha channel. It detects connected regions of transparency, not brightness. The README's talk of "white-background sheets" is aspirational - the actual code, and the node's own tooltip, are explicit that a white-background sheet needs to go through a background-removal step first (BiRefNet, rembg, whatever your pack prefers) to become transparent. Feed it a flat white sheet and the whole canvas is one connected blob.

How it works

The mechanism is textbook connected-component analysis: it takes the alpha channel, thresholds it, finds each distinct connected region with scipy.ndimage.label, computes a bounding box per region, and crops each element out. The knobs:

  • 最小面积过滤(像素数) - components smaller than this (in pixels) get dropped. Default 100; raise it if you're getting noise fragments, lower it to keep tiny details.
  • 裁剪边距 - extra padding (pixels) kept around each element's bounding box. Default 2.
  • 排序方式 - output order: left-to-right/top-to-bottom, top-to-bottom/left-to-right, or by area (largest or smallest first). Game assets usually want a deterministic reading order, so the default reading-order sort is the one to leave alone.
  • seed - a pure cache-buster. It doesn't affect the result; it exists so you can force re-execution in server deployments.

Output is 图像列表, a list of IMAGEs. Transparent regions in each crop are filled with white for the output - which is exactly why the RGBA variant exists.

Installing it

Part of the RUI-Nodes pack ("Rui-Node🐶"). Install once via ComfyUI Manager (search "RUI-Nodes") or:

cd ComfyUI/custom_nodes
git clone https://github.com/rui40000/RUI-Nodes
cd RUI-Nodes
pip install -r requirements.txt

Restart after. It needs scipy for the connected-component labeling - that's in the pack's requirements, and most ComfyUI installs already have it.

Where people get burned

The one real trap is the alpha requirement, and it's worth repeating: white background in, one giant blob out. A white-background sheet is the classic input people try first, and it silently fails by producing a single full-canvas crop. Route the sheet through a background remover first. Second, overlapping elements can't be separated - if two sprites touch even at one pixel, they merge into one component; separate them in the source or raise the area filter so tiny bridges get dropped. And remember the output fills transparency with white, so if you need clean transparent PNGs downstream, this is not the terminal node - its RGBA sibling is.

CategoryRui-Node🐶/图像调节🎨

Inputs (5)

NameTypeDefaultDescription
图像IMAGE待拆分的合图,需自带透明通道(背景为透明)。 节点按 alpha 的连通区域找出各个独立素材并逐个裁出。 白底图请先接抠图节点转成透明再进来,否则整图会被当成一块。
最小面积过滤(像素数)INT1001–50000最小面积(像素数):面积小于此值的连通区域将被过滤,避免噪点碎片。
裁剪边距INT20–50裁剪边距(像素):每个元素裁剪时在包围盒外额外保留的像素边距。
排序方式COMBO从左到右-从上到下输出排序方式:控制拆分后元素的排列顺序。
seedINT00–18446744073709550000随机种子:仅用于强制重新执行节点,不影响实际拆分结果。

Outputs (1)

NameTypeDescription
图像列表IMAGE