LayerUtility: ImageScaleRestore V2 Documentation
Overview
The LayerUtility: ImageScaleRestore V2 node is a versatile tool designed to scale images and their corresponding masks back and forth using various resampling methods within a ComfyUI workflow. This node can adaptively resize images while maintaining the aspect ratio based on different scaling criteria, and it is equipped with functionality to handle multiple image and mask batches efficiently.
Inputs
The LayerUtility: ImageScaleRestore V2 node accepts the following inputs:
-
Image
- Type: IMAGE
- Description: The primary input image(s) to be scaled.
-
Scale
- Type: FLOAT
- Default: 1
- Range: 0.01 to 100
- Description: The scale factor to resize images. A scale of 1 maintains the original size, while values below or above adjust the size proportionally.
-
Method
- Options: [lanczos, bicubic, hamming, bilinear, box, nearest]
- Description: The resampling method to use during the resizing process. Different methods offer varying balances of speed and quality.
-
Scale By
- Options: [by_scale, longest, shortest, width, height, total_pixel(kilo pixel)]
- Description: Determines how the resizing is calculated:
- by_scale: Uses the scale factor directly.
- longest: Scales based on the longest dimension.
- shortest: Scales based on the shortest dimension.
- width: Sets a specific width, maintaining aspect ratio.
- height: Sets a specific height, maintaining aspect ratio.
- total_pixel(kilo pixel): Resizes so that total pixels approximate the given kilopixel value, balancing width and height accordingly.
-
Scale By Length
- Type: INT
- Default: 1024
- Range: 4 to 99,999,999
- Description: The target length for dimensions based on the selected scaling method (e.g., target width, height).
-
Mask (Optional)
- Type: MASK
- Description: An optional mask to be scaled alongside the image(s).
-
Original Size (Optional)
- Type: BOX
- Description: Specifies the target size directly, overriding the calculated size based on scale or other parameters.
Outputs
The node produces the following outputs:
-
Image
- Type: IMAGE
- Description: The resized image(s) as per the scaling criteria and method selected.
-
Mask
- Type: MASK
- Description: The resized mask(s) corresponding to the image(s), if provided.
-
Original Size
- Type: BOX
- Description: The original dimension of the image before resizing.
-
Width
- Type: INT
- Description: The calculated width of the resized image.
-
Height
- Type: INT
- Description: The calculated height of the resized image.
Usage in ComfyUI Workflows
This node can be utilized in workflows where image scaling is a critical step. It allows for the precise resizing of images and masks, making it suitable for:
- Preparing images for various display resolutions.
- Matching image sizes in different layers for compositing.
- Reverting image sizes back to original dimensions after processing.
- Pre-processing images to fit within specified pixel budgets.
By adjusting the scaling method and criteria, users can easily tailor the node to meet specific requirements, enhancing their workflow flexibility.
Special Features or Considerations
- Batch Processing: The node is designed to handle batches of images and masks, making it efficient for large-scale processing tasks.
- Aspect Ratio Maintenance: When resizing, the node ensures that the aspect ratio of the image is preserved unless directed otherwise.
- Flexible Resampling Methods: The node provides multiple resampling options to cater to different quality-speed trade-offs. Methods like Lanczos and Bicubic offer high-quality results, while options like Nearest can be faster.
By carefully choosing parameters based on project requirements, users can leverage the full potential of the LayerUtility: ImageScaleRestore V2 node within their ComfyUI environments.