imagegenerated

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

image
mask
IMAGE
MASK
target_width
INT
target_height
INT
feathering
INT
upscale_method
COMBO
KJNodes

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 NameData TypeRequiredDefault ValueRange/OptionsDescription
imageIMAGEYes--image (Input Parameter): The original image that needs to be adjusted and processed.
upscale_methodCOMBOYes--upscale_method (Input Parameter): Selects the interpolation algorithm to use when downscaling the image is required, such as "lanczos" or "bicubic".
maskMASKNo--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 NameData TypeRequiredDefault ValueRange/OptionsDescription
target_widthINTYes00 - 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_heightINTYes00 - 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.
featheringINTYes00 - 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 NameData TypeDescription
IMAGEIMAGEIMAGE (Output Parameter): Outputs the image after size adjustment.
MASKMASKMASK (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.

The Image Pad For Outpaint Target Size node is from the ComfyUI-KJNodes node package.

Comments

Sign in with GitHub to join the discussion.

Loading comments…