Image Pad For Outpaint Target Size(ImagePadForOutpaintTargetSize)
This node first calculates a scaling factor based on the target width and height, then scales the image to fit within the target canvas while preserving its original aspect ratio.
Image Pad For Outpaint Target Size
The Image Pad For Outpaint Target Size node first calculates a scaling factor based on the target width and height, scaling the image to fit within the target canvas while preserving its original aspect ratio.
The Image Pad For Outpaint Target Size node is a specialized tool for preparing images for outpainting. Its core function is to intelligently adjust an input image to a specified target size while generating a corresponding mask, providing a foundation for subsequent outpainting or image extension operations.
Node Functionality
This node first calculates a scaling factor based on the target width and height, scaling the image to fit within the target canvas while preserving its original aspect ratio. If the target size is smaller than the original image, it uses the user-selected upscaling method (e.g., bilinear, Lanczos) for downsampling. Subsequently, it generates a mask that matches the dimensions of the adjusted image and can optionally apply a feathering effect to the mask edges for smoother transitions.
Node Parameter Description - Image Pad For Outpaint Target Size
Connection Inputs (Inputs)
| Parameter Name | Data Type | Required | Default Value | Range/Options | Description |
|---|---|---|---|---|---|
image | IMAGE | Yes | - | - | image (Input Parameter): The original image that needs to be adjusted and processed. |
upscale_method | COMBO | Yes | - | - | upscale_method (Input Parameter): Selects the interpolation algorithm to use when downscaling the image is required, such as "lanczos" or "bicubic". |
mask | MASK | No | - | - | mask (Input Parameter): Optionally input a custom mask. If provided, the node will scale it to match the dimensions of the processed image. |
Control Parameters (Parameters)
| Parameter Name | Data Type | Required | Default Value | Range/Options | Description |
|---|---|---|---|---|---|
target_width | INT | Yes | 0 | 0 - MAX_RESOLUTION (Step: 8) | target_width (Input Parameter): Specifies the target width for the output image. The value range is from 0 to MAX_RESOLUTION, adjustable in steps of 8. |
target_height | INT | Yes | 0 | 0 - MAX_RESOLUTION (Step: 8) | target_height (Input Parameter): Specifies the target height for the output image. The value range is from 0 to MAX_RESOLUTION, adjustable in steps of 8. |
feathering | INT | Yes | 0 | 0 - MAX_RESOLUTION (Step: 1) | feathering (Input Parameter): Sets the feathering intensity for the edges of the generated mask; a higher value results in a smoother transition. The value range is from 0 to MAX_RESOLUTION, adjustable in steps of 1. |
Output
| Parameter Name | Data Type | Description |
|---|---|---|
| IMAGE | IMAGE | IMAGE (Output Parameter): Outputs the image after size adjustment. |
| MASK | MASK | MASK (Output Parameter): Outputs the mask corresponding to the dimensions of the adjusted image, used to identify the valid area. |
Usage Scenarios
This node is very useful in image outpainting or content generation workflows. For example, when you have a portrait image but wish to extend it into a wider landscape image, you can first use this node to scale the image to the target canvas size and obtain a mask. Then, pass the output image and mask to an outpainting node (such as KSampler), instructing the model to generate new, coherent content in the transparent areas outside the mask.
Notes
Please note that this node is primarily used to prepare the canvas and mask for outpainting; it does not generate new image content itself. If the provided target size is smaller than the original image dimensions, the image will be compressed, which may result in loss of detail.
Image Pad For Outpaint Target Size Node Source Code Link
The Image Pad For Outpaint Target Size node is from the ComfyUI-KJNodes node package.
Comments
Sign in with GitHub to join the discussion.