KJNodes/imagegenerated

Save Image With Alpha(SaveImageWithAlpha)

This node accepts inputs in two tensor formats: `IMAGE` and `MASK`. Internally, it converts the mask data into an alpha channel and combines it with the image data.

Save Image With Alpha

images
mask
filename_prefix
ComfyUI
KJNodes

The Save Image With Alpha node receives inputs in the IMAGE and MASK tensor formats. Internally, it converts the mask data into an Alpha channel and combines it with the image data.

The Save Image With Alpha node is an image processing node. Its core function is to merge the input image and mask and save the result as a PNG format file with a transparency channel. It allows users to embed mask information directly into the image's Alpha channel, thereby generating image files that support transparent backgrounds.

Node Function

This node receives inputs in the IMAGE and MASK tensor formats. Internally, it converts the mask data into an Alpha channel and combines it with the image data. It uses the PIL library for image processing, ultimately saving the composited image in PNG format to ComfyUI's default output directory. It also supports embedding workflow prompt information within the file.

Node Parameter Description - Save Image With Alpha

Connection Inputs (Inputs)

Parameter NameData TypeRequiredDefault ValueValue Range/OptionsDescription
imagesIMAGEYes--images (input parameter): Input the image data to be saved, typically an RGB image.
maskMASKYes--mask (input parameter): Input the mask data corresponding to the image, which will serve as the image's Alpha channel.

Control Parameters (Parameters)

Parameter NameData TypeRequiredDefault ValueValue Range/OptionsDescription
filename_prefixSTRINGYesComfyUI-filename_prefix (input parameter): Sets the prefix for the output filename, used to organize and identify the generated files.

Usage Scenarios

In image editing or compositing workflows, you can use this node when you need to generate an image with custom transparent areas. For example, after completing a person cutout, connecting the generated person image and its corresponding mask to this node will output a PNG image of the person with a transparent background, making it easy to use later in other design software.

Notes

Please note that the input images and masks must correspond one-to-one in the batch dimension. If multiple images and masks are provided, the node will pair them sequentially for processing and save them as multiple files.

The Save Image With Alpha node is from the ComfyUI-KJNodes node package.

Comments

Sign in with GitHub to join the discussion.

Loading comments…