LayerStyle

2167
By chflame
Updated 15 days ago
View on GitHub →See Common Issues →

A set of nodes for ComfyUI that can composite layer and mask to achieve Photoshop like functionality.

Available Nodes

LayerUtility: ICMask

Documentation for LayerUtility: IC Mask Node

Overview

The LayerUtility: IC Mask node is a custom node intended for use in ComfyUI workflows. It allows for the manipulation and combination of images and masks by resizing, positioning, and stitching them together. This functionality is useful for image processing tasks where specific image portions need to be highlighted or combined, especially when dealing with high-resolution images needing consistent processing dimensions.

Functionality

The LayerUtility: IC Mask node performs various operations on input images and masks, including:

  • Resizing images and masks to ensure they fit within a specified output length while maintaining proportionality.
  • Applying padding to images and masks with customizable color options.
  • Concatenating two images either horizontally or vertically based on a specified patch mode.
  • Outputting processed images and masks along with metadata about the image transformation.

Input Types

The node accepts the following inputs:

Required Inputs

  • First Image: This is the primary input image that will undergo resizing and masking operations.

  • Patch Mode: This determines how the images should be combined. There are three options:

    • auto: Automatically determines the best orientation for combining images.
    • patch_right: Concatenates the second image to the right of the first image.
    • patch_bottom: Concatenates the second image below the first image.
  • Output Length: Defines the dimension of the largest side of the output image. This value will be adjusted to be divisible by 64 if it is not already.

  • Patch Color: Specifies the color used to pad the images. The options are:

    • #FF0000 (Red)
    • #00FF00 (Green)
    • #0000FF (Blue)
    • #FFFFFF (White, which is the default)

Optional Inputs

  • First Mask: An optional mask corresponding to the first image.

  • Second Image: An optional secondary image to be combined with the first. If not provided, a blank image of the specified patch color is created.

  • Second Mask: An optional mask corresponding to the second image.

Output Types

The node produces the following outputs:

  • Image: The resultant combined and processed image.

  • Mask: The resultant combined mask, which outlines regions of interest within the image.

  • ICMask Data: Metadata regarding the processed images, including information about offsets, target dimensions, and original dimensions. This data facilitates subsequent processing steps such as further image manipulation or extraction.

Use Cases in ComfyUI Workflows

In a ComfyUI environment, the LayerUtility: IC Mask node is useful for:

  • Creating complex image compositions by combining multiple images and applying additional transformations.
  • Preparing images and masks for further image processing tasks, such as edge detection or feature extraction.
  • Ensuring images meet certain dimensional requirements necessary for integrating with other nodes or exporting to specific formats.

Special Features and Considerations

  • The node automatically adjusts the output_length to be a multiple of 64, ensuring compatibility with image processing algorithms that rely on specific granularity.
  • The choice of patch_mode allows for flexibility in how images and masks are stitched together, facilitating different compositional needs.
  • The node provides an intuitive way to handle images with customizable padding color, allowing easy distinction of borders when overlapping images.
  • While optional masks can enhance image processing precision, the node gracefully handles their absence, defaulting to filled masks as needed.

By integrating the LayerUtility: IC Mask node into a ComfyUI workflow, users can streamline and automate complex image processing tasks, achieving consistent and high-quality results.