ComfyUI > Nodes > ComfyUI-UniversalToolkit > Image Scale By Aspect Ratio (UTK)

ComfyUI Node: Image Scale By Aspect Ratio (UTK)

Class Name

ImageScaleByAspectRatio_UTK

Category
UniversalToolkit/Image
Author
whmc76 (Account age: 1110days)
Extension
ComfyUI-UniversalToolkit
Latest Updated
2026-03-16
Github Stars
0.07K

How to Install ComfyUI-UniversalToolkit

Install this extension via the ComfyUI Manager by searching for ComfyUI-UniversalToolkit
  • 1. Click the Manager button in the main menu
  • 2. Select Custom Nodes Manager button
  • 3. Enter ComfyUI-UniversalToolkit 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
  • 16GB VRAM to 80GB VRAM GPU machines
  • 400+ preloaded models/nodes
  • Freedom to upload custom models/nodes
  • 200+ ready-to-run workflows
  • 100% private workspace with up to 200GB storage
  • Dedicated Support

Run ComfyUI Online

Image Scale By Aspect Ratio (UTK) Description

Adjusts image size while preserving specified aspect ratio, offering flexible resizing options.

Image Scale By Aspect Ratio (UTK):

The ImageScaleByAspectRatio_UTK node is designed to adjust the size of an image while maintaining a specified aspect ratio. This node is particularly useful for artists and designers who need to ensure that their images fit specific dimensions without distorting the original proportions. By allowing you to choose between maintaining the original aspect ratio, using a custom ratio, or specifying a ratio in the form of width:height, this node provides flexibility in how images are resized. It also offers options for scaling to the longest or shortest side of the image, ensuring that the resized image meets your specific requirements. The node can handle both images and masks, making it versatile for various artistic applications.

Image Scale By Aspect Ratio (UTK) Input Parameters:

aspect_ratio

The aspect_ratio parameter determines how the image's proportions are maintained during scaling. You can choose "original" to keep the image's current aspect ratio, "custom" to define your own ratio, or specify a ratio using the format width:height. This parameter is crucial for ensuring that the image is resized without unwanted distortion. There are no explicit minimum or maximum values, but the format must be valid for the node to function correctly.

scale_to_side

The scale_to_side parameter specifies whether the image should be scaled based on its longest or shortest side. This choice affects how the image fits within the target dimensions, allowing you to prioritize either the width or height during the scaling process. This parameter does not have numerical values but rather options like "longest" or "shortest."

crop_position

The crop_position parameter determines where the image will be cropped if the scaling results in dimensions larger than the target size. Options include "center," "top," "bottom," "left," and "right," allowing you to control which part of the image is preserved. This parameter is essential for ensuring that the most important parts of the image remain visible after resizing.

fit_mode

The fit_mode parameter decides how the image should be resized to fit the target dimensions. Options include "crop" for cropping the image to fit and "fill" for resizing the image to fill the target dimensions without cropping. This parameter helps in achieving the desired visual outcome for the resized image.

resize_sampler

The resize_sampler parameter defines the algorithm used for resizing the image. Options include "LANCZOS," "bicubic," "hamming," "bilinear," "box," and "nearest." Each method offers different qualities of resizing, affecting the sharpness and clarity of the final image. Choosing the right sampler can enhance the visual quality of the resized image.

Image Scale By Aspect Ratio (UTK) Output Parameters:

resized_image

The resized_image output is the final image after it has been scaled and possibly cropped according to the specified parameters. This output is crucial as it represents the end result of the node's processing, ready for further use or display.

original_dimensions

The original_dimensions output provides the width and height of the original image before any scaling or cropping was applied. This information is useful for reference and for understanding how much the image has been altered during processing.

output_dimensions

The output_dimensions output indicates the width and height of the image after processing. This helps in verifying that the image has been resized to the intended dimensions.

processed_images_count

The processed_images_count output shows the number of images that have been processed by the node. This is useful for batch processing scenarios where multiple images are handled at once.

Image Scale By Aspect Ratio (UTK) Usage Tips:

  • To maintain the original look of your image, use the "original" aspect ratio option, which ensures no distortion occurs during resizing.
  • When working with images that need to fit specific dimensions, use the "crop" fit mode to ensure the image fills the space without leaving empty areas.
  • Experiment with different resize_sampler options to find the best balance between processing speed and image quality, especially for high-resolution images.

Image Scale By Aspect Ratio (UTK) Common Errors and Solutions:

Error: Image Scale By Aspect Ratio (UTK) execute failed, because the image or mask at least one must be input.

  • Explanation: This error occurs when neither an image nor a mask is provided as input to the node.
  • Solution: Ensure that you provide at least one valid image or mask input before executing the node.

Error: Image or mask dimensions do not match.

  • Explanation: This error indicates that the dimensions of the provided mask do not match those of the image.
  • Solution: Verify that the mask and image have the same dimensions before processing, or adjust them to match.

Warning: Image or mask input is empty, ignoring it.

  • Explanation: This warning suggests that an empty mask was provided, which will be ignored during processing.
  • Solution: Check the mask input to ensure it contains valid data, or remove it if not needed.

Image Scale By Aspect Ratio (UTK) Related Nodes

Go back to the extension to check out more related nodes.
ComfyUI-UniversalToolkit
RunComfy
Copyright 2025 RunComfy. All Rights Reserved.

RunComfy is the premier ComfyUI platform, offering ComfyUI online environment and services, along with ComfyUI workflows featuring stunning visuals. RunComfy also provides AI Models, enabling artists to harness the latest AI tools to create incredible art.

Image Scale By Aspect Ratio (UTK)