ComfyUI Node Runs on cloud

Layers Save

Hand the composite over with the layers still inside

By WASasquatch·Created 3 years ago·Updated 4 days ago· 1,844
Layers Save
  • layers
  • composite
  • files
  • composite
file_formatpsd
root
filename_prefixComfyUI_layers
depth8 bit
compressionrle

A flat PNG is a finished thing. Layers Save writes the same picture as a document somebody can take apart: the plate, the cut-out, the glow and the title as separate layers, each with its name, its place on the canvas, its opacity, its blend mode and whether it was hidden. If your graph assembles a comp out of a stack - Layers from Image Batch, Layer Edit, Layer Fit, the Layer Glow / Shadow / Bevel / Stroke effects, Layers Merge to flatten it - this is how that stack leaves ComfyUI as an editable deliverable.

How it works

It builds the file itself, byte by byte, with no image library in the loop. A PSD gets the standard layer block - Layr at 8-bit, Lr16, Lr32 at the higher depths - with each layer's channels packed as RLE, zip or raw, followed by the flattened picture in the document's merged section.

The layered TIFF is the clever bit: it holds the identical layer block inside its Adobe image source data tag. The file is then two things at once - a normal TIFF whose flattened picture opens in anything, and, to Photoshop and Affinity Photo, a document with layers. That's why tiff is the pick when the file also has to be viewable by someone without Photoshop.

Every layer keeps its identity on the way out, straight off the stack's own record: name, x/y placement, opacity, blend mode, hidden flag, alpha as coverage. A stack whose layers carry a batch is written as one file per frame, numbered in order. And since it's an output node, it writes even with nothing wired after it - no Save Image terminal required.

Inputs that matter

layers is the only required wire, and it has to be an actual stack - feed it a bare image and you'll get a complaint that there's nothing to write.

file_format is psd or tiff; every editor opens a PSD, whereas layered TIFFs are read by Photoshop and Affinity Photo, and only their flattened picture is universal.

root and filename_prefix decide where it lands. root is ComfyUI's output or temp, or any folder added under paths.allow_write in config.yaml. The prefix is the name and any subfolder below that root, and it takes tokens - ComfyUI_layers gives ComfyUI_layers_0001.psd, while [time(%Y-%m-%d)]/shot drops frame one into a dated subfolder. It lands in output/ by default, so if the file belongs somewhere else, say so in the prefix.

depth is where beginners get the wrong answer. 8 bit is what an editor expects and the smallest file. 16 bit is for a plate you'll keep grading afterwards - banding in a sky is real. 32 bit float keeps the exact values off the wire including anything above white, the only setting that doesn't clip a linear-light result. So: 8-bit for handoff, float when the stack came out of the pack's HDR-side work.

compression - rle, zip, none - is all lossless. rle is what editors write themselves and the most compatible; zip shrinks the layers; none is fastest and fattest. Don't agonise.

The optional composite input is the useful trap-avoider: wire a graded picture in and it's stored as the file's preview instead of the node compositing the stack for you, so an editor shows that until it redraws the layers itself. It has to be exactly the canvas size, and it'll tell you both dimensions if it isn't.

Outputs are files - full paths written this run, one per line, in frame order - and composite, the flattened picture from each file as a batch.

Installing it

ComfyUI Manager: search WAS Node Suite v3, install, restart. Manual:

cd ComfyUI/custom_nodes
git clone https://github.com/WASasquatch/was-node-suite-comfyui.git

Nothing to download, nothing to compile, no models, no pip run on startup. ComfyUI 0.14.0+ and Python 3.10+. The pack writes and reads the PSD and TIFF layouts itself, which is why there's no psd-tools dependency to fight with here. It's gated by features.photoshop in config.yaml, on by default.

Common issues

"Handed a stack with no layers in it." You wired an empty stack, or something upstream that isn't one. Layers from Image Batch builds a stack from images; check it with Layers Info, which prints the whole document - canvas size, layer count, visible count, a row per layer.

Canvas too big, or a composite that doesn't fit. A PSD's longest side is capped at 30000 pixels and the writer refuses past that. Wire a composite at the wrong size and the error names both - a two-second fix, since Layers Canvas sets the stack's canvas to match.

A layered TIFF that "has no layers". Hand it to someone on GIMP and they'll see the flattened picture, because GIMP doesn't read the layer block out of that tag. If the recipient's editor is uncertain, ship a PSD.

Old advice doesn't apply. Most threads mentioning this pack are v2-era dependency breakage - Import Failed after an update, opencv-python downgrades. v3 installs zero packages. If something goes wrong now, it's the layer data, not the environment.

CategoryWAS Suite/Image/Layers

Inputs (7)

NameTypeDefaultDescription
layersLAYERSThe stack to write, one file per frame it carries; LAYERS.
file_formatCOMBOpsd'psd' = a Photoshop document, which every editor opens; 'tiff' = a layered TIFF, whose layers Photoshop and Affinity Photo read and whose flattened picture opens anywhere at all.
rootCOMBOWhich folder the files land in: ComfyUI's own 'output' or 'temp', or any folder added under paths.allow_write in config.yaml, listed by its own name.
filename_prefixSTRINGComfyUI_layersName and folder below the root, before the number. `ComfyUI_layers` gives `ComfyUI_layers_0001.psd`; `plates/shot` puts it in that subfolder. Tokens expand, so `[time(%Y-%m-%d)]/shot` dates the folder.
depthCOMBO8 bit'8 bit' = 256 levels a channel, the smallest file and what every editor expects; '16 bit' = 65536 levels, which keeps a graded plate off a banded gradient; '32 bit float' = the exact values on the wire, keeping anything above white for further grading.
compressionCOMBOrle'rle' = the packing an editor writes itself, the most widely read; 'zip' = smaller layers, read by Photoshop 6 and later; 'none' = stored as they are, largest and fastest. All three are lossless, and the flattened picture is packed the same either way.
compositeoptIMAGEA flattened picture to store as the file's preview instead of the one this node composites; IMAGE. Wire the graded result so an editor shows that until it redraws the layers itself. It has to be the size of the canvas.

Outputs (2)

NameTypeDescription
filesSTRINGFull path of every file written this run, one per line, in frame order.
compositeIMAGEThe flattened picture stored in each file, as a batch in frame order; IMAGE.