Nodes Browser
ComfyDeploy: How ComfyUI-AlphaFlatten works in ComfyUI?
What is ComfyUI-AlphaFlatten?
This node takes a batch of images with alpha channels (RGBA format) and combines them into a single image, respecting the transparency of each layer. It's particularly useful for compositing multiple masked elements (like faces) into a single image.
How to install it in ComfyDeploy?
Head over to the machine page
- Click on the "Create a new machine" button
- Select the
Edit
build steps - Add a new step -> Custom Node
- Search for
ComfyUI-AlphaFlatten
and select it - Close the build step dialig and then click on the "Save" button to rebuild the machine
ComfyUI-AlphaFlatten
A custom node for ComfyUI that flattens a batch of images with alpha channels into a single image, similar to Photoshop's flatten function.
Description
This node takes a batch of images with alpha channels (RGBA format) and combines them into a single image, respecting the transparency of each layer. It's particularly useful for compositing multiple masked elements (like faces) into a single image.
Features
- Combines multiple images with alpha channels into a single image
- Supports various background options:
- Black background
- White background
- Transparent background (preserves alpha channel)
- Custom color background (RGB values)
- Properly handles alpha blending for realistic compositing
- Works with any number of images in a batch
Installation
-
Clone this repository into your ComfyUI's
custom_nodes
directory:cd ComfyUI/custom_nodes git clone https://github.com/yourusername/ComfyUI-FlattenByAlpha.git
-
Restart ComfyUI if it's already running.
Usage
- In ComfyUI, find the "Flatten Images By Alpha" node under the "image/processing" category.
- Connect a batch of RGBA images to the "images" input.
- Select a background color option:
black
: Use a black backgroundwhite
: Use a white backgroundtransparent
: Maintain transparency in the outputcustom
: Define a custom RGB color using the color sliders
- If you selected
custom
, adjust the R, G, and B values to create your desired background color. - The node will output a single flattened image.
Use Cases
This node is particularly useful for:
- Compositing multiple face or object masks into a single image
- Combining multiple transparent layers from image generation
- Creating complex compositions from individually generated elements
- Simulating Photoshop's "flatten layers" functionality within ComfyUI workflows
Technical Details
The node processes each image in the batch sequentially, blending them together based on their alpha channels. Images later in the batch will appear "on top" of earlier images, similar to how layers work in image editing software.
For transparent backgrounds, the node preserves the alpha channel in the output, allowing for further compositing in downstream nodes.
Requirements
- ComfyUI
- PyTorch