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: ImageMaskScaleAs

LayerUtility: Image Mask Scale As - Documentation

Overview

The "LayerUtility: Image Mask Scale As" node is a component in the ComfyUI framework designed to scale images and masks according to a reference. This node assists in resizing and fitting images and masks to match the dimensions of a specified target or reference image while maintaining various fitting and interpolation methods.

Functionality

The node primarily focuses on resizing images and masks, which is vital for maintaining consistency across various graphical elements in a workflow. It supports both image and mask inputs, allowing for flexible usage depending on the user's requirements.

Inputs

Required Inputs

  1. Scale As: This input defines the reference dimensions that the images and masks will be scaled to. It serves as the template for deciding the final output size.

  2. Fit Mode: Several fitting methods govern how the scaling is performed:

    • Letterbox: Adds padding to retain the aspect ratio.
    • Crop: Trims parts of the image or mask to fit.
    • Fill: Stretches to fill the target dimensions.
  3. Method Mode: This parameter decides the interpolation method for resizing:

    • Lanczos
    • Bicubic
    • Hamming
    • Bilinear
    • Box
    • Nearest

Optional Inputs

  1. Image: The input image(s) to be resized. It is optional and can be used based on user needs.

  2. Mask: The mask(s) that need resizing. This optional input allows users to scale corresponding masks.

Outputs

  1. Image: The resized image(s) according to the specified dimensions and fit/method modes.

  2. Mask: The resized mask(s) corresponding to the provided images.

  3. Original Size: An array detailing the original width and height of the image/mask before scaling.

  4. Width: The width of the scaled output.

  5. Height: The height of the scaled output.

Application in ComfyUI Workflows

In ComfyUI workflows, this node is invaluable for maintaining consistency in image processing pipelines. It ensures that images and masks align with the desired dimensions, which is crucial for tasks like composite image creation, analysis, and visualization. It can be paired with other nodes to perform tasks such as texture mapping, mask alignment, and automated graphic preparation.

Special Features and Considerations

  • Flexible Interpolation: The node offers six different methods for resizing, each with unique characteristics that optimize for specific outcomes, such as preserving details or smoothing transitions.

  • Error Handling: If no applicable image or mask is found, the node gracefully logs an error, keeping workflows robust and easy to debug.

  • Dynamic Sizing: Designed to accommodate varying image and mask size inputs, allowing for broader application across different projects without needing manual adjustments.

This guide provides the necessary information to utilize the "LayerUtility: Image Mask Scale As" node effectively within ComfyUI. Users can explore more about its use and updates by visiting the repository on GitHub.