Nodes/TrentNodes/PSD Layer Names
ComfyUI Node

PSD Layer Names

Read a PSD's Layer List Before You Touch It — No Rasterizing

By TrentHunter82·Created 9 months ago·Updated 4 days ago· 36
PSD Layer Names
    • all_names
    • name_at_index
    • count
    psd_path
    index0
    include_groupsfalse

    You've got a Photoshop file from a client and you need to swap one layer's artwork - but which layer is the logo, and what is it even called? This node answers that in milliseconds: it walks the PSD's layer tree and lists every layer name, with no rasterization and no manifest side effects. It's the reconnaissance step before PSD Layer Save As PSD, because that node targets layers by name, and names are only useful if you know them.

    What it does

    Required inputs are psd_path and index (which layer to surface in the name_at_index output - 0 is the bottom). The one optional, include_groups, defaults to off to match the splitter's filtering (groups hidden); flip it on if you specifically want to target a group by name.

    The outputs are the whole story:

    • all_names - a multiline string of every layer name. Wire this into a Show Text node and you have the full inventory of the file.
    • name_at_index - the name at the index you set, after the same filtering the splitter uses. This is the value you feed into PSD Layer Save As PSD's target_layer_name.
    • count - how many layers survived filtering.

    That last bit matters more than it looks: because the filtering matches the splitter, the index you type here lines up with the indices the splitter produces. If you've been staring at a splitter manifest, you can cross-reference. If the PSD has groups, remember the default hides them - your count and your splitter output will agree, but neither counts group rows.

    The workflow it enables

    Discover → target → replace:

    1. Point this at the PSD, wire all_names to a text display, see exactly what's in the file.
    2. Set index to the layer you care about, read name_at_index.
    3. Feed that name into PSD Layer Save As PSD, and your replacement lands on the right layer by name - even if the file's layer order changes later, because you matched a name, not a position.

    This is the node that makes the save-as node usable at all, honestly. Typing layer names blind into a text box is how you end up replacing the background instead of the logo.

    Installing it

    Part of TrentNodes; one install covers all of it:

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

    Or ComfyUI Manager, search "Trent Nodes" - with the standing caveat that the author's day-one repo rename left a duplicate registry entry, so Manager occasionally flags the pack as "unsafe" and the manual clone is the reliable fallback. This node uses psd-tools (in requirements) and nothing else - no models, no downloads.

    Where it trips people up

    Non-Latin layer names are the classic gotcha in PSD tooling, and this is the part of the pack that handles them properly - PSD Layer Save As PSD writes the proper Unicode tagged block so Chinese, Korean, or accented layer names survive. If a name looks wrong or a replacement isn't matching, double-check include_groups is set the way you expect; a group-wrapped layer can hide from the list when groups are off.

    CategoryTrent/PSD

    Inputs (3)

    NameTypeDefaultDescription
    psd_pathSTRINGAbsolute path to the .psd
    indexINT00–9999Which layer to return in name_at_index (0 = bottom)
    include_groupsoptBOOLEANfalseMatch the splitter default: groups hidden. Turn on if you want to target a group by name.

    Outputs (3)

    NameTypeDescription
    all_namesSTRINGMultiline list of every layer - feed into a Show Text node to see what's in the PSD
    name_at_indexSTRINGThe layer name at `index` (after the same filtering PSDLayerSplitter uses). Feed into PSDLayerSaveAsPSD's target_layer_name.
    countINTHow many layers the PSD has (after filtering)