ComfyUI > Nodes > ComfyUI Layer Style > LayerUtility: ImageScaleByAspectRatio V2

ComfyUI Node: LayerUtility: ImageScaleByAspectRatio V2

Class Name

LayerUtility: ImageScaleByAspectRatio V2

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

Resize images while preserving aspect ratio with various scaling options for accurate and efficient image preparation.

LayerUtility: ImageScaleByAspectRatio V2:

The LayerUtility: ImageScaleByAspectRatio V2 node is designed to help you resize images while maintaining their aspect ratio. This node is particularly useful when you need to scale images to fit specific dimensions without distorting their original proportions. It offers various scaling options, such as scaling to the longest or shortest side, width, height, or even a specific total pixel count. This flexibility ensures that your images are resized accurately and efficiently, making it an essential tool for AI artists who need to prepare images for different applications or outputs.

LayerUtility: ImageScaleByAspectRatio V2 Input Parameters:

aspect_ratio

This parameter determines the aspect ratio to be used for scaling the image. You can choose between 'original' to maintain the original aspect ratio, 'custom' to specify a custom ratio, or provide a specific ratio in the format 'width:height'. This setting ensures that the image is scaled correctly according to the desired proportions.

proportional_width

When using a custom aspect ratio, this parameter specifies the width component of the ratio. It works in conjunction with proportional_height to define the custom aspect ratio. This allows for precise control over the image's final dimensions.

proportional_height

Similar to proportional_width, this parameter specifies the height component of the custom aspect ratio. Together, these parameters allow you to define a specific aspect ratio for scaling the image.

fit

This parameter determines how the image should fit within the target dimensions. Options may include 'contain', 'cover', or other fitting methods. This setting ensures that the image is resized appropriately without unwanted cropping or padding.

method

This parameter specifies the resampling method to be used during the scaling process. Options include 'LANCZOS', 'bicubic', 'hamming', 'bilinear', 'box', and 'nearest'. Each method offers different levels of quality and performance, allowing you to choose the best option for your specific needs.

round_to_multiple

This parameter allows you to round the target dimensions to a specific multiple. For example, setting this to 10 will round the width and height to the nearest multiple of 10. This can be useful for ensuring that the resized image dimensions are compatible with certain requirements or constraints.

scale_to_side

This parameter determines which side of the image should be scaled to the specified length. Options include 'longest', 'shortest', 'width', 'height', and 'total_pixel(kilo pixel)'. This setting provides flexibility in how the image is resized, ensuring that it meets your specific requirements.

scale_to_length

This parameter specifies the target length for the side chosen in scale_to_side. It defines the final dimension for the selected side, ensuring that the image is scaled accurately.

image

This parameter accepts the input image to be scaled. It is the primary image that will be resized according to the specified parameters.

mask

This optional parameter accepts a mask image that will be scaled along with the primary image. This ensures that any associated masks are resized consistently with the main image.

LayerUtility: ImageScaleByAspectRatio V2 Output Parameters:

resized_image

The primary output of this node is the resized image. This image has been scaled according to the specified parameters, maintaining the desired aspect ratio and fitting within the target dimensions.

resized_mask

If a mask image was provided as an input, this output will contain the resized mask. The mask is scaled consistently with the primary image, ensuring that any regions of interest are accurately represented.

LayerUtility: ImageScaleByAspectRatio V2 Usage Tips:

  • To maintain the original aspect ratio of an image, set the aspect_ratio parameter to 'original'.
  • Use the scale_to_side and scale_to_length parameters to precisely control the final dimensions of the image.
  • Experiment with different resampling methods using the method parameter to find the best balance between quality and performance for your specific use case.
  • If you need the resized image dimensions to be multiples of a specific value, use the round_to_multiple parameter to achieve this.

LayerUtility: ImageScaleByAspectRatio V2 Common Errors and Solutions:

Invalid aspect ratio format

  • Explanation: The aspect ratio provided is not in the correct format (e.g., 'width:height').
  • Solution: Ensure that the aspect ratio is specified in the correct format, such as '16:9' or '4:3'.

Unsupported resampling method

  • Explanation: The resampling method specified is not supported.
  • Solution: Choose a valid resampling method from the available options: 'LANCZOS', 'bicubic', 'hamming', 'bilinear', 'box', or 'nearest'.

Image or mask not provided

  • Explanation: The input image or mask is missing.
  • Solution: Ensure that you provide an input image and, if necessary, a mask image for the node to process.

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