ComfyOnline
JWImageResizeByLongerSide

Introduction:

comfyui-various Introduction

The comfyui-various repository is a collection of custom nodes for ComfyUI, focusing on image operations. It provides a range of utilities for image loading, saving, resizing, and manipulation, aiming to enhance the image processing capabilities within ComfyUI.

JWImageResizeByLongerSide Introduction

The JWImageResizeByLongerSide node is a custom node within the comfyui-various suite designed to resize images based on their longer side. This node ensures that the longer side of the image is scaled to a specified size, while the shorter side is scaled proportionally to maintain the aspect ratio.

JWImageResizeByLongerSide Input

The JWImageResizeByLongerSide node accepts the following inputs:

  • image (IMAGE): The input image to be resized. This should be a torch tensor in the format (batch_size, height, width, channels).
  • size (INT): The target size for the longer side of the image. The shorter side will be scaled proportionally.
  • interpolation_mode (["bicubic", "bilinear", "nearest", "nearest exact"]): The interpolation mode to use for resizing. Options include:
    • bicubic: Bicubic interpolation.
    • bilinear: Bilinear interpolation.
    • nearest: Nearest neighbor interpolation.
    • nearest exact: Nearest neighbor interpolation (exact).

JWImageResizeByLongerSide Output

The JWImageResizeByLongerSide node produces the following output:

  • IMAGE (IMAGE): The resized image as a torch tensor in the format (batch_size, new_height, new_width, channels). The longer side of the image will be equal to the specified size.

JWImageResizeByLongerSide Usage Tips

  • Maintaining Aspect Ratio: This node is particularly useful when you need to resize images while preserving their original aspect ratio. It ensures that the longer side matches the specified size, and the shorter side is adjusted accordingly.
  • Interpolation Mode: Choose the appropriate interpolation mode based on the desired quality and performance. bicubic generally provides better quality but may be slower, while nearest is faster but may result in pixelation.
  • SDXL Compatibility: This node can be helpful in preparing images for SDXL, which often requires specific resolutions. However, for more direct SDXL resolution handling, consider the JWImageResizeToClosestSDXLResolution or JWImageCropToClosestSDXLResolution nodes.
  • Integer Rounding: Note that the new dimensions for the shorter side are rounded to the nearest integer, which may result in slight variations in the final size.