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: ImageScaleByAspectRatio V2

LayerUtility: ImageScaleByAspectRatio V2 - Documentation

Overview

The LayerUtility: ImageScaleByAspectRatio V2 node is a powerful image processing tool within the ComfyUI framework. It enables users to scale images while preserving or altering their aspect ratios. This node provides flexibility in resizing images according to various user-defined criteria, utilizing several fitting modes and rendering methods to achieve the desired output.

Functionality

This node is designed to adjust the dimensions of images based on a specified aspect ratio. It can either maintain the original aspect ratio or use a custom one, ensuring that the resulting image’s width and height fit particular constraints. This is especially useful in workflows where images need to be standardized in size while preserving certain visual characteristics.

Inputs

This node accepts the following inputs:

Required Inputs

  1. Aspect Ratio: Defines how the image's dimensions are proportioned. Options include:

    • original: Maintains the original aspect ratio of the image.
    • custom: Allows for a user-defined aspect ratio.
    • Pre-defined ratios such as 1:1, 3:2, 4:3, 16:9, 2:3, 3:4, 9:16.
  2. Proportional Width & Proportional Height: Integers that define the custom width and height ratios when custom is selected as the aspect ratio.

  3. Fit Mode: Specifies how the image will be adjusted within the new dimensions. Options include letterbox, crop, and fill.

  4. Method Mode: Selects the algorithm for image resampling during resizing. Available methods are lanczos, bicubic, hamming, bilinear, box, and nearest.

  5. Round to Multiple: Ensures that the final image dimensions are rounded up to a specified multiple. Options range from 8 to 512, or None.

  6. Scale To Side: Determines which side of the image is used for scaling. Options include None, longest, shortest, width, height, and total_pixel(kilo pixel).

  7. Scale To Length: An integer specifying the target length for scaling, applicable when Scale To Side is not None.

  8. Background Color: A string value defining the background color used when resizing with letterbox fit mode.

Optional Inputs

  • Image: The image data to be processed.
  • Mask: An optional mask that can be applied to the image for additional processing.

Outputs

The node produces the following outputs:

  1. Image: The processed image, resized according to the specified parameters.
  2. Mask: The processed mask, if one was provided and applicable for transformation.
  3. Original Size: A tuple containing the original width and height of the image.
  4. Width & Height: Integers indicating the final width and height of the processed image.

Usage in ComfyUI Workflows

Within a ComfyUI workflow, this node can be employed to standardize image sizes, adapt images for display on various devices, or prepare images for further processing steps. The flexibility in aspect ratio selection and the variety of fit and method modes make it a versatile node suitable for numerous scenarios. Users can efficiently incorporate this node to ensure consistent image dimensions across different workflow stages, especially in graphics design or digital content creation pipelines.

Special Features and Considerations

  • Customizable Aspect Ratios: Users can keep the original aspect ratio or define a custom one, providing great flexibility in meeting specific design requirements.
  • Multiple Resizing Methods: Various methods are available for resizing images, allowing users to prioritize quality or speed based on their needs.
  • Flexible Dimension Constraints: With options to scale based on width, height, or pixel count, users can meet specific project constraints effectively.
  • Background Color for Letterbox Fit: When using the letterbox fit mode, users can specify a background color to fill any space around the resized image.

Consider the implications of aspect ratio changes and rounding to multiples on the image's visual appearance, as they can impact the final result significantly, especially in design-sensitive workflows.