Introducing the LayersSaver Node for ComfyUI

A ComfyUI custom node to save images into PSD files, with the possibility of having different layers based on input masks

Introducing the LayersSaver Node for ComfyUI

The LayersSaver nodes, developed by Alessandro Zonta, is a powerful custom addition to ComfyUI, designed to enhance image manipulation workflows. Two nodes are available on the packadge. The first node allows users to create and manage image layers based on input masks, saving the results into a PSD file. The second node does a similar thing but only from th einput images. It can receive a batched image and every image in the batch is going to be saved as a separate layer on the ouput PSD. This functionality is particularly valuable for graphic design, image processing, and other tasks requiring layer-based image manipulation.

How It Works

  1. Input Image Handling: The first node processes a single input image, ensuring the removal of the batch dimension for simplicity. The second nodes processes a infinite bach dimension input image.
  2. Mask Application: Multiple masks are applied to the input image, creating distinct layers for each masked region.
  3. Original Image Inclusion: Users can optionally include the original image as a separate layer in the PSD file.
  4. Alpha Channel Management: Ensures the input image includes an alpha channel, facilitating transparency.
  5. Dynamic PSD Naming: If a filename isn’t specified, the node generates a unique PSD filename based on the current timestamp.
  6. PSD File Creation: The final image layers are saved into a PSD file, which can then be used in various image editing software.

The Idea Behind It

The idea behind the LayersSaver node is to streamline the process of creating and managing image layers within ComfyUI. By allowing users to segment images into separate layers based on masks, it provides a high degree of flexibility and control over image editing. This is especially useful in professional graphic design and advanced image processing tasks, where layer manipulation is crucial.

Example Workflow
Example Workflow

Installation

To integrate the LayersSaver node into ComfyUI, follow these steps:

  1. Clone the repository into your ComfyUI custom_nodes directory:

    git clone https://github.com/alessandrozonta/ComfyUI-Layers
    

    or find the Custom Node from your ComfyUI-Manager

  2. Install the necessary libraries by running:

    pip install pytoshop -I --no-cache-dir
    pip install psd-tools --no-deps
    
  3. Restart ComfyUI to load the new node.

Conclusion

The LayersSaver node is an invaluable tool for anyone involved in graphic design or image processing. By providing a streamlined method for creating and managing image layers, it enhances the functionality of ComfyUI, making complex image editing tasks more efficient and manageable. Whether you’re a professional designer or a hobbyist, this node offers the flexibility and power needed to take your projects to the next level.

For more details, visit the GitHub page.

Alessandro Zonta
Alessandro Zonta
Lead Machine Learning Engineer