Load & Resize Image(LoadAndResizeImage)
This node processes images based on the PIL library, supports common image formats, and can automatically correct EXIF orientation.
Load And Resize Image
The Load & Resize Image node processes images based on the PIL library, supports common image formats, and can automatically correct EXIF orientation.
The Load & Resize Image node is a powerful tool for image loading and preprocessing. Its core functionality is to load images from ComfyUI's input directory and optionally resize them, process transparency channels, and generate masks, preparing them for subsequent image generation or editing workflows.
Node Functionality
This node processes images based on the PIL library, supports common image formats, and can automatically correct EXIF orientation. Its technical core lies in its ability to perform precise scaling and padding of images based on user-defined target dimensions and aspect ratio preservation options. Additionally, it can extract specified color channels (such as Alpha, Red, Green, Blue) as masks or fill transparent areas with a specified background color.
Node Parameter Description - Load & Resize Image
Connection Inputs (Inputs)
| Parameter Name | Data Type | Required | Description |
|---|---|---|---|
image | COMBO (image list) | Yes | Select an image from ComfyUI's input directory. The widget lists available image files. |
mask_channel | COMBO | Yes | Channel to use for the mask output. Options include Alpha, Red, Green, Blue, and None. |
Control Parameters (Parameters)
| Parameter Name | Data Type | Required | Default Value | Value Range / Options | Description |
|---|---|---|---|---|---|
resize | BOOLEAN | Yes | False | - | Whether to enable the image resizing function. When set to True, the image will be scaled according to subsequent parameters. |
width | INT | Yes | 512 | 0 – MAX_RESOLUTION (Step: 8) | Target width for resizing (used only when resize is enabled). |
height | INT | Yes | 512 | 0 – MAX_RESOLUTION (Step: 8) | Target height for resizing (used only when resize is enabled). |
repeat | INT | Yes | 1 | 1 – 4096 (Step: 1) | Number of times the loaded image will be repeated along the batch dimension. |
keep_proportion | BOOLEAN | Yes | False | - | Whether to maintain the original aspect ratio of the image when resizing. |
divisible_by | INT | Yes | 2 | 0 – 512 (Step: 1) | Aligns the resized image dimensions (width and height) to be integer multiples of this value. |
background_color | STRING | Yes | "" | - | Fills transparent (Alpha) areas with the specified color. Accepts hex colors (e.g. #RRGGBB) or named colors. |
Outputs
| Parameter Name | Data Type | Description |
|---|---|---|
image | IMAGE | The processed image tensor (with transparency filled if background_color is specified). |
mask | MASK | Mask extracted from the chosen mask_channel. |
width | INT | Actual width of the output image (after any resizing or proportion adjustments). |
height | INT | Actual height of the output image. |
image_path | STRING | File path of the loaded image. |
Usage Scenarios
This node is very useful in workflows that require batch processing or uniform input image dimensions. For example, before starting an image-to-image workflow with Stable Diffusion, you can use this node to load a reference image, precisely scale it to the model's required 512x512 resolution, and simultaneously extract its Alpha channel as a mask to protect specific areas during repainting.
Notes
Please note that when keep_proportion (maintain proportion) is enabled, the actual output dimensions may not exactly match the set width and height. The system will adjust based on the original image's aspect ratio and the divisible_by parameter. Additionally, the background_color parameter requires input in a specific color string format (e.g., "#RRGGBB" or color names).
Load & Resize Image Node Source Code Link
The Load & Resize Image node is from the ComfyUI-KJNodes node package.
Comments
Sign in with GitHub to join the discussion.