ComfyUI > Nodes > ComfyUI Layer Style > LayerUtility: ImageScaleRestore

ComfyUI Node: LayerUtility: ImageScaleRestore

Class Name

LayerUtility: ImageScaleRestore

Category
😺dzNodes/LayerUtility
Author
chflame163 (Account age: 445days)
Extension
ComfyUI Layer Style
Latest Updated
2024-06-24
Github Stars
0.64K

How to Install ComfyUI Layer Style

Install this extension via the ComfyUI Manager by searching for ComfyUI Layer Style
  • 1. Click the Manager button in the main menu
  • 2. Select Custom Nodes Manager button
  • 3. Enter ComfyUI Layer Style in the search bar
After installation, click the Restart button to restart ComfyUI. Then, manually refresh your browser to clear the cache and access the updated list of nodes.

Visit ComfyUI Online for ready-to-use ComfyUI environment

  • Free trial available
  • High-speed GPU machines
  • 200+ preloaded models/nodes
  • Freedom to upload custom models/nodes
  • 50+ ready-to-run workflows
  • 100% private workspace with up to 200GB storage
  • Dedicated Support

Run ComfyUI Online

LayerUtility: ImageScaleRestore Description

Resize and restore images while maintaining quality, supporting multiple methods and aspect ratio preservation.

LayerUtility: ImageScaleRestore:

The LayerUtility: ImageScaleRestore node is designed to help you resize and restore images to a specific scale or dimension while maintaining the quality and integrity of the original image. This node is particularly useful for AI artists who need to adjust the size of their images for various applications, such as preparing images for different display formats or ensuring consistency across a series of images. The node supports multiple resizing methods, including bicubic, hamming, bilinear, box, and nearest, allowing you to choose the most suitable method for your specific needs. Additionally, it can handle masks and maintain the aspect ratio by scaling based on the longest side of the image. This flexibility ensures that your images are resized accurately and efficiently, preserving important details and minimizing distortion.

LayerUtility: ImageScaleRestore Input Parameters:

image

This parameter represents the input image or a batch of images that you want to resize. The images should be provided as tensors. The function will process each image in the batch individually.

scale

This parameter defines the scaling factor for resizing the image. It is a float value where a value greater than 1 will enlarge the image, and a value less than 1 will reduce the image size. The default value is 1.0.

method

This parameter specifies the resizing method to be used. The available options are "bicubic", "hamming", "bilinear", "box", and "nearest". Each method has its own characteristics in terms of quality and processing time. The default method is "lanczos".

scale_by_longest_side

This boolean parameter determines whether the image should be scaled based on its longest side. If set to True, the image will be resized such that the longest side matches the specified longest_side parameter. The default value is False.

longest_side

This parameter specifies the target length of the longest side of the image when scale_by_longest_side is set to True. It is an integer value that defines the desired size in pixels.

mask

This optional parameter allows you to provide a mask for the image. The mask should be provided as a tensor. If a mask is provided, it will be resized along with the image to maintain alignment.

original_size

This optional parameter allows you to specify the original size of the image as a tuple (width, height). If provided, the image will be resized to this exact size instead of using the scale factor.

LayerUtility: ImageScaleRestore Output Parameters:

resized_images

This output parameter returns the resized images as a tensor. The images are resized according to the specified scale or dimensions, maintaining the quality and aspect ratio as per the input parameters.

resized_masks

This output parameter returns the resized masks as a tensor, if a mask was provided. The masks are resized to match the dimensions of the resized images, ensuring proper alignment.

original_dimensions

This output parameter provides the original dimensions of the input image(s) as a list [width, height]. This information can be useful for reference or further processing.

target_width

This output parameter returns the target width of the resized image(s). It is an integer value representing the width in pixels.

target_height

This output parameter returns the target height of the resized image(s). It is an integer value representing the height in pixels.

LayerUtility: ImageScaleRestore Usage Tips:

  • To maintain the aspect ratio of your images while resizing, use the scale_by_longest_side parameter and specify the desired longest_side length.
  • Choose the appropriate resizing method based on your quality and performance needs. For high-quality results, consider using "bicubic" or "lanczos".
  • If you need to resize a batch of images, ensure that all images are provided as tensors in the image parameter for consistent processing.
  • When working with masks, provide the mask tensor in the mask parameter to ensure that the mask is resized along with the image, maintaining proper alignment.

LayerUtility: ImageScaleRestore Common Errors and Solutions:

"Image size must be greater than 4 pixels"

  • Explanation: The target width or height of the resized image is less than 4 pixels, which is not supported.
  • Solution: Ensure that the target dimensions are at least 4 pixels by adjusting the scale, longest_side, or original_size parameters.

"Invalid resizing method"

  • Explanation: The specified resizing method is not recognized.
  • Solution: Use one of the supported methods: "bicubic", "hamming", "bilinear", "box", "nearest", or "lanczos".

"Mask dimensions do not match image dimensions"

  • Explanation: The provided mask does not match the dimensions of the input image.
  • Solution: Ensure that the mask tensor has the same dimensions as the input image tensor before providing it to the node.

LayerUtility: ImageScaleRestore Related Nodes

Go back to the extension to check out more related nodes.
ComfyUI Layer Style
RunComfy

© Copyright 2024 RunComfy. All Rights Reserved.

RunComfy is the premier ComfyUI platform, offering ComfyUI online environment and services, along with ComfyUI workflows featuring stunning visuals.