Nodes/TrentNodes/PSD Layer Splitter
ComfyUI Node

PSD Layer Splitter

Turning a Photoshop File Into Something ComfyUI Can Actually Touch

By TrentHunter82·Created 9 months ago·Updated 4 days ago· 36
PSD Layer Splitter
    • images
    • masks
    • layer_names
    • layer_count
    • output_folder
    psd_path
    output_dir
    layer_sizingcropped
    layer_typespixel,type,shape,smartobject,fill
    include_hiddenfalse
    extract_groupsfalse
    save_manifesttrue
    overwritetrue

    A .psd is the one image format ComfyUI will not open on its own - it's a proprietary layer container, and the UI wants pixels. This node is the front door of the pack's whole PSD toolkit: it rasterizes every layer of a Photoshop file into its own PNG, writes a _manifest.json capturing where each layer sat, and hands you a folder that every other PSD node in the pack reads back. Split once, then iterate on the layers without re-parsing the PSD.

    How it works

    Under the hood it uses psd-tools, the third-party parser that's the only realistic way to read Adobe's closed format on a machine without Photoshop. For each layer it renders a PNG (the filename encodes index, total count, layer kind, and name - so a single file tells you how many layers the document has), and the manifest records position, size, opacity, blend mode, visibility, and group path. That manifest is the backbone: the compositor, the background detector, and the flatten nodes all read it to reconstruct the stack.

    Two decisions on the splitter shape everything downstream:

    • layer_sizing - cropped (default) saves each layer at its own bounds only; canvas places each layer on the full document canvas at its real position. Cropped is smaller and faster; canvas is what you want if you'll feed layers straight into something that expects full-frame images.
    • layer_types - comma-separated kinds to extract, default pixel,type,shape,smartobject,fill. Adjustment layers are left out by default (they affect the stack below them, and rasterizing them as standalone layers misrepresents their effect). Note the tooltip's warning: group is deliberately not in the default list - groups are handled by extract_groups, off by default, because exporting a group and its children produces duplicates that cover the children when you recomposite.

    Inputs and outputs that matter

    psd_path (the file) and output_dir (where the PNGs and manifest go) are the two you always set. include_hidden (default off) - include layers the PSD marks hidden; handy for poking at disabled layers, but turn it back off before recompositing or you'll see things that were supposed to stay hidden. overwrite (default on) lets re-runs refresh the folder.

    Outputs: images (list of layer RGB images), masks (per-layer alpha, white = transparent - the inverted convention this pack uses), layer_names, layer_count, and output_folder, which you chain straight into the PSD Layer Loader or Compositor. It's an output node, so it also reports to the UI.

    Installing it

    Part of TrentNodes; one install:

    cd ComfyUI/custom_nodes
    git clone https://github.com/TrentHunter82/TrentNodes.git
    cd TrentNodes
    pip install -r requirements.txt
    

    ComfyUI Manager ("Trent Nodes") also works, with the standing caveat that the author renamed the repo on day one, leaving two registry entries that make Manager occasionally flag the pack as "unsafe" - the clone above is the reliable path. psd-tools (the actual PSD parser) is in requirements.txt.

    Where people get burned

    • Recomposited layers doubled up - that's extract_groups left on. Keep it off unless you specifically want group rasters.
    • Hidden layers appearing - include_hidden is on from a previous experiment.
    • Index drift - the moment you change layer_types, indices shift (because adjustment and group layers are filtered in or out). Re-run the whole chain after changing filters, or the indices in your downstream nodes will point at the wrong layers.
    CategoryTrent/PSD

    Inputs (8)

    NameTypeDefaultDescription
    psd_pathSTRINGAbsolute path to the .psd file
    output_dirSTRINGDirectory to save extracted layer PNGs and manifest
    layer_sizingCOMBOcroppedcropped = layer bounds only. canvas = placed on full PSD canvas at correct position
    layer_typesSTRINGpixel,type,shape,smartobject,fillComma-separated layer kinds to extract: pixel, type, shape, smartobject, fill, adjustment. Note: 'group' is handled by extract_groups (off by default) because exporting both a group and its children produces duplicate layers and shifts indices.
    include_hiddenoptBOOLEANfalseInclude layers marked as hidden in the PSD
    extract_groupsoptBOOLEANfalseIf True, also rasterize Group nodes as their own layer. Off by default because the group's children are already exported individually, so including the group produces a duplicate that covers the children when recomposited.
    save_manifestoptBOOLEANtrueSave _manifest.json alongside the PNGs with full metadata
    overwriteoptBOOLEANtrueOverwrite existing files in the output directory

    Outputs (5)

    NameTypeDescription
    imagesIMAGEEach extracted layer as an RGB image
    masksMASKAlpha mask per layer (inverted: white = transparent)
    layer_namesSTRINGOriginal layer names
    layer_countINTNumber of extracted layers
    output_folderSTRINGPath to the output folder (chain to PSD Layer Loader)