KJNodes/imagegenerated

ImagePad KJ(ImagePadKJ)

This node supports multiple fill modes, including replicating edge pixels, using a solid color, or applying a blur effect, and can process both image data and corresponding mask data simultaneously.

Image Pad KJ

image
mask
images
masks
left
INT
right
INT
top
INT
bottom
INT
extra_padding
INT
pad_mode
COMBO
color
0, 0, 0
target_width
INT
target_height
INT
KJNodes

The ImagePad KJ node supports multiple padding modes, including replicating edge pixels, using a solid color, or applying blur effects. It can process both image data and corresponding mask data simultaneously.

ImagePad KJ is an image processing node specifically designed to add borders or padding areas to input images and optional masks. Its core functionality allows users to precisely control the expansion dimensions and padding methods around the image, thereby adjusting the image composition or preparing the canvas for subsequent processing steps.

Node Functionality

This node supports multiple padding modes, including replicating edge pixels, using a solid color, or applying blur effects. It can process both image data and corresponding mask data simultaneously. It accepts standard IMAGE and MASK tensors as inputs, defines the padding area by specifying pixel values for the top, bottom, left, and right directions, and ensures synchronized dimension changes for the output image and mask.

Node Parameter Description - ImagePad KJ

Connection Inputs (Inputs)

Parameter NameData TypeRequiredDefault ValueValue Range/OptionsDescription
imageIMAGEYes--image (Input Parameter): The original image to be padded. The node will apply the specified padding settings to this image.
maskMASKNo--mask (Input Parameter): Optional input, the mask corresponding to the image. The node will scale it to the same size as the image and then apply the same padding settings.

Control Parameters (Parameters)

Parameter NameData TypeRequiredDefault ValueValue Range/OptionsDescription
pad_modeCOMBOYesedge"edge", "edge_pixel", "color", "pillarbox_blur"edge_pixel (replicate a single edge pixel), color (use a specified color), pillarbox_blur (blur edges to create a cinematic pillarbox effect).
leftINTYes00 - MAX_RESOLUTION (Step: 1)left (Input Parameter): Specifies the width of the padding area to add to the left side of the image, in pixels. Value range is 0 to MAX_RESOLUTION, with a step of 1.
rightINTYes00 - MAX_RESOLUTION (Step: 1)right (Input Parameter): Specifies the width of the padding area to add to the right side of the image, in pixels. Value range is 0 to MAX_RESOLUTION, with a step of 1.
topINTYes00 - MAX_RESOLUTION (Step: 1)top (Input Parameter): Specifies the height of the padding area to add to the top of the image, in pixels. Value range is 0 to MAX_RESOLUTION, with a step of 1.
bottomINTYes00 - MAX_RESOLUTION (Step: 1)bottom (Input Parameter): Specifies the height of the padding area to add to the bottom of the image, in pixels. Value range is 0 to MAX_RESOLUTION, with a step of 1.
extra_paddingINTYes00 - MAX_RESOLUTION (Step: 1)A uniform pixel value added to the specified padding amounts for all four sides (top, bottom, left, right). Value range is 0 to MAX_RESOLUTION, with a step of 1.
colorSTRINGYes0, 0, 0-Color as RGB values in range 0-255 or 0.0-1.0, or color name or hex code
target_widthINTNo0 - MAX_RESOLUTION (Step: 1)-
target_heightINTNo0 - MAX_RESOLUTION (Step: 1)-

Output

Parameter NameData TypeDescription
imagesIMAGEimages (Output Parameter): Outputs the padded image after processing.
masksMASKmasks (Output Parameter): Outputs the mask after synchronized padding processing.

Usage Scenarios

This node is very useful in workflows that require standardizing irregularly sized images to a specific aspect ratio. For example, before batch processing images from different sources for input into an AI model with fixed dimensions, it can be used to add black bars (pillarbox) or blur the background, ensuring all input dimensions are consistent while preserving the original image content without distortion.

Notes

Please note that excessively large padding values may cause the final image resolution to exceed the system's processing capacity. Additionally, when a mask is provided, the node will automatically scale it to the same size as the input image before performing the padding operation.

The ImagePad KJ node is from the ComfyUI-KJNodes node package.

Comments

Sign in with GitHub to join the discussion.

Loading comments…