Resize Image v2(ImageResizeKJv2)
This node technically supports multiple upsampling algorithms (such as bilinear, Lanczos, etc.) for image scaling and can simultaneously process images and their associated mask channels.
Image Resize K Jv2
The Resize Image v2 node technically supports multiple upsampling algorithms (such as bilinear, Lanczos, etc.) to handle image scaling and can simultaneously process the image and its associated mask channel.
The Resize Image v2 node is a powerful image resizing tool that allows you to precisely scale or crop an input image to specified width and height. It not only supports simple stretching but also provides various processing modes that maintain the original image's aspect ratio to meet different resizing requirements across various scenarios.
Node Functionality
This node technically supports multiple upsampling algorithms (such as bilinear, Lanczos, etc.) to handle image scaling and can simultaneously process the image and its associated mask channel. Based on the user-selected "keep proportion" mode, it intelligently calculates the final output dimensions and optionally adjusts the size to be an integer multiple of a specified number. This is particularly useful for subsequent processing steps that require specific size alignment.
Node Parameter Description - Resize Image v2
Connection Inputs (Inputs)
| Parameter Name | Data Type | Required | Default Value | Value Range/Options | Description |
|---|---|---|---|---|---|
image | IMAGE | Yes | - | - | image (Input Parameter): The input image that needs resizing. This is the primary object processed by the node. |
upscale_method | STRING | Yes | - | - | upscale_method (Input Parameter): Selects the interpolation algorithm used for image upscaling, such as "nearest-exact" or "lanczos", which affects the quality of the upscaled image. |
mask | MASK | No | - | - | mask (Optional Input): An optional mask that will be resized along with the image. |
Control Parameters (Parameters)
| Parameter Name | Data Type | Required | Default Value | Value Range/Options | Description |
|---|---|---|---|---|---|
keep_proportion | COMBO | Yes | stretch | "stretch", "resize", "pad", "pad_edge", "pad_edge_pixel", "crop", "pillarbox_blur", "total_pixels" | Scale proportionally, pad, crop, etc. Default is "stretch". |
crop_position | COMBO | Yes | center | "center", "top", "bottom", "left", "right" | Top, bottom, left, right. |
width | INT | Yes | 512 | 0 - MAX_RESOLUTION (Step: 1) | width (Target Dimension): The desired width for the output image. The actual output width may differ (e.g., in aspect ratio preservation modes). |
height | INT | Yes | 512 | 0 - MAX_RESOLUTION (Step: 1) | height (Target Dimension): The desired height for the output image. The actual output height may differ (e.g., in aspect ratio preservation modes). |
pad_color | STRING | Yes | 0, 0, 0 | - | Color to use for padding. Default is "0, 0, 0" (black). |
divisible_by | INT | Yes | 2 | 0 - 512 (Step: 1) | divisible_by (Input Parameter): Adjusts the final output width and height to be integer multiples of this value. Range is 0 to 512, step is 1. |
device | COMBO | No | cpu | "cpu", "gpu" | - |
Output
| Parameter Name | Data Type | Description |
|---|---|---|
| IMAGE | IMAGE | IMAGE (Output Parameter): The final image after resizing. |
| width | INT | width (Output Parameter): The actual width value of the output image, which may differ from the input target width (e.g., in aspect ratio preservation modes). |
| height | INT | height (Output Parameter): The actual height value of the output image, which may differ from the input target height (e.g., in aspect ratio preservation modes). |
| mask | MASK | mask (Output Parameter): Outputs the mask after synchronized resizing. |
Usage Scenarios
In an image preprocessing workflow, you can connect this node after any image source to standardize input images of varying sizes to the model's required resolution. For example, before a Stable Diffusion text-to-image pipeline, you can use it to ensure all input images meet the 512x512 requirement, while using the "pad" mode to add borders and preserve the original composition.
Notes
Please note that when selecting "crop" mode, if the original image's aspect ratio does not match the target ratio, parts of the image content will be permanently removed. Additionally, combining a high target resolution with certain upsampling methods may consume significant computational resources.
Resize Image v2 Node Source Code Link
The Resize Image v2 node is from the ComfyUI-KJNodes node package.
Comments
Sign in with GitHub to join the discussion.