Split Layer Stack
Split Layer Stack — turning the layered latent into actual layers
- images
- composite
- layers
- alpha_masks
- layer_count
Qwen-Image-Layered doesn't output layers the way you'd hope. It outputs a stack: a single VAE decode where the first slice is a flattened composite of the whole image and every slice after it is one RGBA layer, back-to-front. To a human that's one batch of confusing images. Split Layer Stack is the node that makes it real - it pulls the composite off the front, hands you the layers, gives you the alpha channels as proper MASKs, and tells you how many layers you actually got.
How it works
The layered latent holds layers + 1 temporal slices, and the model pads unused slots with blank layers, so you can't just trust your layers setting. This node splits slice 0 out as composite and the remainder as layers, then extracts the alpha channel from each layer as a MASK (it'll substitute an opaque mask for any layer that arrived without one).
Two knobs:
- drop_blank_layers (default off) - when on, layers whose average alpha is below
blank_thresholdget dropped, so the unused padding slots vanish from your stack instead of haunting it. Turn this on and you get clean numbered layers. - blank_threshold (default 0.01) - how blank "blank" means. A genuinely empty padding layer has essentially zero alpha, so 0.01 is fine for most runs; you'd only raise it if the model is leaving faint ghost layers you want gone.
The four outputs
- composite - slice 0, the flattened reconstruction. The official ComfyUI template cuts this away with LatentCutToBatch, but keeping it is a free sanity check: it should look like your input image.
- layers - the RGBA layers, back-to-front, ready for Save Layers (RGBA), Merge Layer Range, or SolidifyAlpha.
- alpha_masks - the same layers as MASKs, which is what you want if you're feeding a compositing or inpainting pipeline that speaks masks rather than RGBA.
- layer_count - how many layers survived (after blank-dropping). Wire this into a loop or a text overlay if you want to automate around however many the model decided to use.
Wiring it in
In the pack's example graph, the order matters: the sampler's latent comes out with layers on the temporal axis, so LatentCutToBatch first converts that to a batch axis, then VAEDecode, then Split Layer Stack. Skip that reshape step and you'll be decoding a latent that isn't shaped the way this node expects. After the split, the layers go to the save node and the composite goes wherever you want to eyeball the reconstruction.
Installing
It's part of ComfyUI-StableLayers, one install for all six nodes:
cd ComfyUI/custom_nodes
git clone https://github.com/tggo/ComfyUI-StableLayers
or ComfyUI Manager → ComfyUI-StableLayers → restart. No extra dependencies for this node.
Gotchas
Don't expect layer_count to equal your layers input - that's the padding, and it's normal. If your layers come back with alpha all over the place (limbs at half transparency), that's the model's soft matte, and it's a SolidifyAlpha job, not a bug here. And if you're feeding the composite out as your "result image," remember it's the model's flattened reconstruction, not your original input - close, but worth checking before you ship it.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| images | IMAGE | — | |
| drop_blank_layers | BOOLEAN | false | — |
| blank_threshold | FLOAT | 0.0100–1 | — |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| composite | IMAGE | — |
| layers | IMAGE | — |
| alpha_masks | MASK | — |
| layer_count | INT | — |