Nodes/WAS Node Suite v3/Layers from Image Batch
ComfyUI Node Runs on cloud

Layers from Image Batch

Turn frames into a stack, each in its own place

By WASasquatch·Created 3 years ago·Updated 4 days ago· 1,844
Layers from Image Batch
  • images
  • layers
  • bounds
  • masks
  • names
  • layers
  • count
placement
offset_x0
offset_y0
canvas_width0
canvas_height0
name_prefixlayer

Layers from Image Batch is the node that builds a layer stack out of a batch of images - one layer per frame, lowest first. The reason it exists is placement: Add Layer puts every frame of a batch at the same spot, which is fine for a flipbook but useless when your frames are different crops that need to land back where they came from. Wire bounds in here and each frame lands where its rectangle says - which is exactly how a stack that Layers to Image Batch took apart goes back together.

The round-trip glue

The canonical use is the split/process/rejoin loop. Layers to Image Batch pulls a stack apart into frames + masks + bounds. You filter, grade or detail those frames individually. Then Layers from Image Batch takes the processed batch, and if you kept the bounds wire from the first node, every frame drops back into its original position on the canvas. Same idea applies to a set of crops a detector found - a whole composite reassembled from pieces, no manual coordinates.

The matching makes this robust: it pairs by order, not by name, so as long as your processing doesn't reorder the batch the geometry just works. Frame order is lowest-in-stack first, same convention on both sides.

When you don't have bounds

Without a bounds wire, placement decides where frames go:

  • all at 0, 0 piles them on top of each other.
  • stepped by offset moves each frame offset_x/offset_y past the one below it - handiest for fanning a batch out to inspect it as layers.
  • spread across the canvas lays them left to right and wraps.

Fewer bound rows than frames and the extras fall back to placement. You can also feed masks (what each frame covers) and names (in frame order - overrides name_prefix), and hand an existing layers stack in to append the new batch on top of it.

The optional extras are where the node earns its keep in odd workflows: mask is used for every frame when it's a single mask, or paired frame-by-frame when it's a batch - which is the standard way to rebuild a stack of cut-outs that each carried their own transparency.

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", restart. Needs ComfyUI 0.14.0+ and Python 3.10+; v3 installs no pip packages.

Where people trip

Order is everything: if you rebuild a stack with the batch reversed, layers that used to be on top end up at the bottom and your composite inverts - check that your processing step didn't flip the frame order. And if bounds are missing or short, frames silently fall back to the placement strategy instead of erroring, which produces a tidy pile at 0,0 that looks broken until you notice there's no bounds wire. Name layers early via names if you plan to address them by name later; the name_prefix default ('layer', 'layer 2'...) is fine for throwaway stacks but useless for telling 'sky' from 'subject'.

CategoryWAS Suite/Image/Layers

Inputs (11)

NameTypeDefaultDescription
imagesIMAGEThe frames to stack, lowest in the stack first. One layer is made per frame.
placementCOMBOWhere a frame goes when no bounds are wired. `all at 0, 0` piles them up; `stepped by offset` moves each one offset_x and offset_y past the one below, which fans a batch out; `spread across the canvas` lays them left to right and wraps.
offset_xINT0-16384–16384Pixels each frame sits right of the one below it on `stepped by offset`. 0 = straight on top, 24 = 24px right each time.
offset_yINT0-16384–16384Pixels each frame sits below the one below it on `stepped by offset`. 0 = straight on top, 24 = 24px down each time.
canvas_widthINT00–16384Width the stack is drawn on. 0 = no canvas of its own, so Create Layered Image sizes it to whatever the layers reach; 1920 pins it.
canvas_heightINT00–16384Height the stack is drawn on. 0 = no canvas of its own; 1080 pins it. Read only alongside a canvas_width above 0.
name_prefixSTRINGlayerWhat each layer is called when no names are wired, with its number after it: 'layer' gives layer 1, layer 2. Blank leaves them unnamed.
layersoptLAYERSA stack the new layers are added on top of. Left unwired the batch becomes a stack of its own.
boundsoptIMAGE_BOUNDSWhere each frame sits, one row per frame, as Layers to Image Batch and Mask to Bounds answer them. Fewer rows than frames and the rest fall back to placement.
masksoptMASKWhat each frame covers, white where it paints, as every mask in this pack reads. One mask is used for every frame; a batch is paired frame by frame.
namesoptARRAYWhat each layer is called, in the same order as the frames, as Layers to Image Batch answers them. Overrides name_prefix.

Outputs (2)

NameTypeDescription
layersLAYERSThe stack, numbered from 0 at the back, for Create Layered Image, Layers Merge or any of the effects.
countINTHow many layers the stack holds once the batch was added.