PSD Layer Flatten (RGBA)
The Flatten Node That Speaks Standard ComfyUI Mask
- image
- mask
Flattening a range of PSD layers into one image is a one-line ask, but the mask that comes with it can silently wreck a workflow if it uses the wrong polarity. This variant exists so you don't have to think about that: it outputs the flattened composite and a mask in the standard ComfyUI convention - white = opaque, black = transparent - ready to feed into inpainting, compositing, or any generic mask consumer.
What it is
Same inputs as its sibling PSD Layer Flatten: folder_path (a splitter output folder), start_index / end_index (inclusive range, 0 = bottom - wire them from PSDBackgroundDetect's bg_start/bg_end), background_color (transparent / white / black / hex), and respect_visibility (default on, skips hidden layers). The outputs are the flattened image as a 4-channel RGBA tensor with alpha preserved, plus mask in the standard white-opaque convention.
Why there are two of these
The pack's own splitter and loader emit masks the Photoshop way - inverted, white = transparent - because that's how alpha reads when you're reconstructing a stack. That convention is wrong for most of ComfyUI, which expects white to mean "this region is selected/opaque." So the pack ships two flattens that do the same rasterization but hand you masks in opposite polarities. If your mask is heading into an inpainting node, a SAM-driven process, or any standard mask input, use this one. If you're staying inside the pack's own convention for everything downstream, the non-RGBA variant keeps you consistent.
It's a small thing, but it's exactly the kind of small thing that turns a 10-minute workflow into an hour of "why is everything inverted."
When you'd reach for it
The classic path: PSDBackgroundDetect returns a range → this node flattens just the background layers into one image → you run that through a background-removal or image-editing pass → then recomposite. Because the flattened output is a single RGBA image with a standards-compliant mask, it slots into ComfyUI's normal image/mask tooling without adapter nodes.
Installing it
Part of TrentNodes; one install serves the whole pack:
cd ComfyUI/custom_nodes
git clone https://github.com/TrentHunter82/TrentNodes.git
cd TrentNodes
pip install -r requirements.txt
ComfyUI Manager ("Trent Nodes") works too, with the standing caveat: the author's day-one repo rename left two registry entries, and Manager occasionally flags the pack as "unsafe" - clone manually if it refuses. It reads the splitter's folder; no models, no downloads.
The one thing to remember
If your flattened image looks right but everything downstream is backwards, check whether you grabbed this variant or the other one. The image outputs match; the masks don't. That's the entire difference, and it's also the entire point.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| folder_path | STRING | Folder from PSDLayerSplitter (must contain _manifest.json) | |
| start_index | INT | 00–9999 | First layer index to include (0 = bottom). Wire from PSDBackgroundDetect bg_start. |
| end_index | INT | 00–9999 | Last layer index to include (inclusive). Wire from PSDBackgroundDetect bg_end. |
| background_color | STRING | transparent | Canvas backdrop: 'transparent', 'white', 'black', or hex like '#FFFFFF' |
| respect_visibility | BOOLEAN | true | If True, skip layers marked hidden in the original PSD |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | Flattened RGBA composite of the selected layers (4-channel, alpha preserved) |
| mask | MASK | Alpha mask using standard ComfyUI convention: white = opaque/selected, black = transparent |