A set of nodes for ComfyUI that can composite layer and mask to achieve Photoshop like functionality.
The LayerUtility: ImageMaskScaleAsV2
node is part of the ComfyUI project, specifically under the LayerUtility category. This node is designed to facilitate the scaling and resizing of images and masks, ensuring they conform to the dimensions of a reference image or tensor. This utility proves useful in various scenarios where consistent image and mask sizes are required, particularly within layered image compositions.
The node performs the following primary functions:
The LayerUtility: ImageMaskScaleAsV2
node accepts multiple inputs to customize its operation. Inputs are categorized as either required or optional:
scale_as: A reference image or tensor indicating the target dimensions that images and masks should be scaled to. This input determines the final size of processed outputs.
fit: Specifies how the image should fit within the target dimensions. Options include:
letterbox
: Adds padding while preserving the image's aspect ratio.crop
: Cuts the image to match the aspect ratio, potentially removing parts of it.fill
: Stretches or compresses the image to fit the dimensions exactly.method: Determines the resampling method to be used. Options consist of:
lanczos
bicubic
hamming
bilinear
box
nearest
background_color: A string input representing the color to be used as a background during resizing, specified in hexadecimal format (e.g., "#FFFFFF" for white).
image: A collection of images to be resized. If no images are provided, only masks will be processed.
mask: A collection of masks to be resized. If no masks are provided, only images will be processed.
The node produces several outputs:
In ComfyUI workflows, the LayerUtility: ImageMaskScaleAsV2
node is utilized to ensure images and masks are uniformly scaled. This consistent resizing is crucial in operations that involve compositing images with precise layering, where uniformity in dimensions is required for seamless integration. Typical uses include:
Background Color Customization: By allowing users to specify a background color, this node provides additional customization for scenarios where padding is added to fit images.
Flexible Fitting Methods: The node supports diverse fitting and resampling methods, enabling users to balance speed and quality, depending on the specific requirements of their project.
Error Handling and Logging: The node includes logging mechanisms to inform users when images or masks are successfully processed or if any issues arise, aiding in debugging and workflow validation.
Modularity: The node can be used in isolation or as part of a larger workflow, making it a versatile tool within the ComfyUI suite for image manipulation tasks.