Layer Select
Keep only the layers that match
- layers
- layers
- count
- dropped
Layer Select is the inverse of Layer Remove, and together they're how you slice a composite into the piece you actually want to work on. Select keeps the layers that match and drops the rest: a run of the stack by index, a name, a visibility state, or any combination. Use it to isolate one layer for a filter, pull just the visible layers out of a working document, or cut a stack down to size before flattening.
The filters
Same three axes as Layer Remove, same semantics - which is convenient because the two nodes read identically and differ only in what survives:
- Index range -
first_indextolast_index, counting 0 from the bottom. 0 and -1 together span every layer. - Name -
matchiscontains('sky' keeps Sky and Sky Backdrop) orexact. Blank keeps every name in the range. - Visibility -
any,visible only, orhidden only. "Isolate the visible layers for a preview" is one node: keepvisible only, and every hidden experiment vanishes from the output.
Where this shines is routing one layer through the rest of the pack. Want to grade just the sky? Select the layer named sky, run it out through Layers to Image Batch, filter it, and put it back with Layer Replace Image. Want to composite only the foreground over a fresh background? Select by the names you gave your foreground pieces and send the reduced stack to Create Layered Image.
Outputs
You get the matched layers (renumbered from 0 at the back), plus count - how many came through - and dropped - how many were left behind. The counts exist so a switch can handle the empty case and so a filter that grabbed too much shows: if you expected two layers and count says six, your name filter is broader than you thought, and you find out before you flatten rather than after.
Installing it
Part of WAS Node Suite:
cd ComfyUI/custom_nodes
git clone https://github.com/WASasquatch/was-node-suite-comfyui.git
or ComfyUI Manager → "WAS Node Suite v3", then restart. Requires ComfyUI 0.14.0+ and Python 3.10+; no pip packages to install in v3.
Where people trip
People write Select where they meant Remove (or vice versa) because both offer the same dropdowns - check which one you placed when the output is inverted from expectations; Remove keeps the non-matching layers, Select keeps the matching ones. The subtler one: Select with visibility = hidden only keeps the hidden layers and drops the visible ones, which sounds like a contradiction until you remember hidden layers are still real data you might want to salvage. And since any selection renumbers survivors from 0, run Select before addressing layers by index downstream - or stick to layer_name for everything after a filter, which is what the pack is clearly built around.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| layers | LAYERS | The stack to filter. Wire in Add Layer, Layer Edit or anything else answering a LAYERS document. | |
| first_index | INT | 0-16384–16384 | Lowest layer kept, counting 0 from the back of the stack. -1 is the front layer, -2 the one under it. |
| last_index | INT | -1-16384–16384 | Highest layer kept, counted the same way. -1 = the front of the stack, so 0 and -1 together keep every layer. |
| name | STRING | Text a layer's name has to carry. Blank keeps every name. Case is ignored, so 'sky' matches Sky. | |
| match | COMBO | How name is compared. 'contains' keeps Sky Backdrop for 'sky'; 'exact' keeps only a layer called exactly that. | |
| visibility | COMBO | Which layers survive by their switch. 'any' ignores it, 'visible only' keeps what the compositor draws, 'hidden only' keeps what it skips. |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| layers | LAYERS | The layers that matched, numbered from 0 at the back, for Create Layered Image or another edit. |
| count | INT | How many layers came through, for a switch that handles one. |
| dropped | INT | How many the filter left behind, so a filter that took too much shows. |