Extensions/ComfyUI APZmedia PSD Tools
ComfyUI Extension

ComfyUI APZmedia PSD Tools

This extension provides PSD layer saving functionalities with mask support for ComfyUI.

By APZmedia·Created about a year ago·Updated about a year ago· 1
APZmedia/APZmedia-ComfyUI-PSDtools
Nodes—
On cloudLocal install
Stars1
Updatedabout a year ago
Readme

ComfyUI APZmedia PSD Tools

Custom ComfyUI nodes for seamless PSD file integration with Photoshop. Save and load images as PSD layers with mask support.

Features

  • Multi-layer PSD Creation: Save 1-10 images as separate layers in a single PSD file
  • PSD Layer Loading: Extract specific layers and masks from existing PSD files
  • Mask Support: Apply masks to individual layers with automatic canvas positioning
  • Flexible Inputs: All layer inputs are optional - connect only what you need
  • Auto-dependency Installation: Dependencies install automatically on first load

Installation

  1. Copy to ComfyUI custom nodes directory:

    ComfyUI/custom_nodes/APZmedia-ComfyUI-PSDtools/
    
  2. Restart ComfyUI

Dependencies will install automatically. If installation fails, see troubleshooting.

Nodes

APZmedia PSD Multilayer Saver

Category: image/psd

Saves up to 10 images as layers in a PSD file.

Inputs (all optional):

  • output_dir (STRING): Output directory (default: "./output")
  • filename_prefix (STRING): Filename prefix (default: "output")
  • layer1-layer10 (IMAGE): Images for each layer
  • mask1-mask10 (MASK): Masks for each layer
  • layer_name1-layer_name10 (STRING): Custom layer names

Outputs: None (writes to disk)

APZmedia PSD Layer Loader

Category: image/psd

Loads PSD files and extracts specific layers.

Inputs:

  • psd_file (STRING): Path to PSD file
  • layer_index (INT): Layer index to extract (0-based)
  • load_mask (COMBO): Load mask ("true"/"false", default: "true")

Outputs:

  • image (IMAGE): Extracted layer
  • mask (MASK): Layer mask
  • layer_name (STRING): Layer name
  • layer_count (INT): Total layers in PSD

Usage Examples

Basic Multi-layer Saving

  1. Connect images to layer1, layer2, etc.
  2. Set custom layer names: "Background", "Character", "Effects"
  3. Add masks if needed
  4. Run workflow to create PSD

Loading PSD Files

  1. Set PSD file path
  2. Select layer index (0-based)
  3. Choose whether to load mask
  4. Use extracted image and mask in workflow

Mask Extraction

The loader uses a sophisticated multi-method approach:

  1. Mask Object Extraction: Primary method for PSD layer masks
  2. Alpha Channel Extraction: Fallback for transparency-based masks
  3. Channel Data Extraction: Advanced fallback for complex PSD structures

Canvas Positioning: Automatically handles mask positioning to match full image dimensions.

Troubleshooting

Common Issues

"No layers or masks are being saved"

  • Connect at least one layer input

"Failed to save PSD file"

  • Check output directory permissions
  • Ensure sufficient disk space

"Layer index out of range"

  • Verify layer index is within valid range (0 to layer_count-1)

Dependencies not installing

  • Check internet connection
  • Try manual installation: pip install psd-tools>=1.9.0

Manual Installation

If auto-installation fails:

cd ComfyUI/custom_nodes/APZmedia-ComfyUI-PSDtools/
python install_for_comfyui.py

Technical Details

Dependencies: psd-tools, Pillow, torch, numpy File Format: Adobe Photoshop PSD (CS6+ compatible) Performance: Optimized for ComfyUI tensor operations

License

MIT License - see LICENSE for details.

Changelog

v0.2.1

  • Simplified to essential nodes only
  • Removed pytoshop dependency
  • Improved mask handling with PIL compositing
  • Enhanced error handling and auto-installation

For support, open an issue on GitHub.