ComfyUI  >  Nodes  >  Image Resize for ComfyUI >  Image Resize

ComfyUI Node: Image Resize

Class Name

ImageResize

Category
image
Author
palant (Account age: 5062 days)
Extension
Image Resize for ComfyUI
Latest Updated
1/18/2024
Github Stars
0.1K

How to Install Image Resize for ComfyUI

Install this extension via the ComfyUI Manager by searching for  Image Resize for ComfyUI
  • 1. Click the Manager button in the main menu
  • 2. Select Custom Nodes Manager button
  • 3. Enter Image Resize for ComfyUI 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

Image Resize Description

Adjust image dimensions with precision, flexibility, upscaling, downscaling, crop, pad, and fine-tuning options.

Image Resize:

The ImageResize node is designed to help you adjust the dimensions of your images with precision and flexibility. Whether you need to resize, crop, or pad your images to fit specific dimensions or aspect ratios, this node provides a comprehensive set of tools to achieve your goals. It supports both upscaling and downscaling, ensuring that your images maintain their quality regardless of the size adjustments. The node also allows for fine-tuning through parameters like crop and pad positions, making it ideal for preparing images for various applications, from digital art to machine learning datasets.

Image Resize Input Parameters:

pixels

This parameter represents the input image that you want to resize. It is required and should be provided in the form of an image tensor.

action

This parameter determines the type of action to be performed on the image. The available options are resize only, crop to ratio, and pad to ratio. The default action is resize only.

smaller_side

This parameter sets the target size for the smaller side of the image. It accepts integer values ranging from 0 to 8192, with a default value of 0. Setting this parameter helps maintain the aspect ratio while resizing.

larger_side

This parameter sets the target size for the larger side of the image. It accepts integer values ranging from 0 to 8192, with a default value of 0. This is useful for ensuring that the image does not exceed a specific dimension.

scale_factor

This parameter allows you to manually set a scaling factor for resizing the image. It accepts float values ranging from 0.0 to 10.0, with a default value of 0.0. This parameter is particularly useful when you need precise control over the scaling process.

resize_mode

This parameter specifies the mode of resizing. The available options are reduce size only, increase size only, and any. This allows you to control whether the image should only be downscaled, upscaled, or resized in any direction.

side_ratio

This parameter sets the target aspect ratio for cropping or padding. It accepts a string in the format width:height, with a default value of 4:3. This is useful for ensuring that the image fits a specific aspect ratio.

crop_pad_position

This parameter determines the position for cropping or padding. It accepts float values ranging from 0.0 to 1.0, with a default value of 0.5. This allows you to control the alignment of the crop or pad operation.

pad_feathering

This parameter sets the amount of feathering to apply when padding the image. It accepts integer values ranging from 0 to 8192, with a default value of 20. Feathering helps to blend the padded areas smoothly with the original image.

mask_optional

This optional parameter allows you to provide a mask for the image. If not provided, a default mask of zeros will be used. The mask should be in the form of a tensor and should match the dimensions of the input image.

Image Resize Output Parameters:

IMAGE

This output parameter represents the resized image. It is the main result of the node's operation and will be in the form of an image tensor.

MASK

This output parameter represents the mask associated with the resized image. It is useful for applications that require both the image and its mask, such as segmentation tasks.

Image Resize Usage Tips:

  • To maintain the aspect ratio while resizing, set either the smaller_side or larger_side parameter and leave the other at its default value.
  • Use the crop_pad_position parameter to control the alignment of the crop or pad operation, especially when dealing with images that need to fit specific aspect ratios.
  • When upscaling images, choose the increase size only option in the resize_mode parameter to ensure that the image quality is preserved.
  • Utilize the pad_feathering parameter to smoothly blend padded areas with the original image, which is particularly useful for creating seamless backgrounds.

Image Resize Common Errors and Solutions:

Invalid input parameters

  • Explanation: This error occurs when one or more input parameters are not valid.
  • Solution: Ensure that all input parameters are within their specified ranges and formats. Double-check the values for smaller_side, larger_side, scale_factor, and other parameters.

Mask dimension mismatch

  • Explanation: This error occurs when the provided mask does not match the dimensions of the input image.
  • Solution: Ensure that the mask has the same height and width as the input image. You can use interpolation to resize the mask to match the image dimensions.

Scale factor out of range

  • Explanation: This error occurs when the calculated scale factor is not within the acceptable range for the chosen resize mode.
  • Solution: Adjust the smaller_side, larger_side, or scale_factor parameters to ensure that the scale factor falls within the acceptable range for the chosen resize_mode.

Image Resize Related Nodes

Go back to the extension to check out more related nodes.
Image Resize for ComfyUI
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.