ComfyUI > Nodes > ComfyUI-LogicUtils > Compose RGBA Image From Mask

ComfyUI Node: Compose RGBA Image From Mask

Class Name

ComposeRGBAImageFromMask

Category
image
Author
aria1th (Account age: 3016days)
Extension
ComfyUI-LogicUtils
Latest Updated
2026-01-21
Github Stars
0.1K

How to Install ComfyUI-LogicUtils

Install this extension via the ComfyUI Manager by searching for ComfyUI-LogicUtils
  • 1. Click the Manager button in the main menu
  • 2. Select Custom Nodes Manager button
  • 3. Enter ComfyUI-LogicUtils in the search bar
After installation, click the Restart button to restart ComfyUI. Then, manually refresh your browser to clear the cache and access the updated list of nodes.

Visit ComfyUI Online for ready-to-use ComfyUI environment

  • Free trial available
  • 16GB VRAM to 80GB VRAM GPU machines
  • 400+ preloaded models/nodes
  • Freedom to upload custom models/nodes
  • 200+ ready-to-run workflows
  • 100% private workspace with up to 200GB storage
  • Dedicated Support

Run ComfyUI Online

Compose RGBA Image From Mask Description

Integrates a mask into an image to create an RGBA image, enabling transparency and layering.

Compose RGBA Image From Mask:

The ComposeRGBAImageFromMask node is designed to seamlessly integrate a mask into an existing RGB or RGBA image, effectively transforming it into an RGBA image. This node is particularly useful for AI artists who need to apply masks to images for various creative effects, such as transparency or layering. By adding an alpha channel to an image, this node allows for more complex image compositions and manipulations. The node's primary function is to take an image and a mask, and optionally invert the mask, to produce a new image where the mask defines the transparency of each pixel. This capability is essential for tasks that require precise control over image transparency and layering, making it a valuable tool in digital art and design workflows.

Compose RGBA Image From Mask Input Parameters:

image

The image parameter represents the input image that you want to modify by adding a mask. This image can be in RGB or RGBA format, meaning it can have either three channels (red, green, blue) or four channels (red, green, blue, alpha). The image serves as the base onto which the mask will be applied, and its dimensions will determine the final size of the output image. The image should be a tensor, and if it is on a GPU, it will be moved to the CPU for processing.

mask

The mask parameter is a crucial component that defines the transparency levels to be applied to the input image. It should be a single-channel tensor with values typically ranging from 0 to 1, where 0 represents full transparency and 1 represents full opacity. The mask is reshaped to ensure it matches the dimensions of the image, and if necessary, it is resized using bilinear interpolation to fit the image's dimensions. This parameter allows you to control which parts of the image are visible and which are transparent.

invert

The invert parameter is a boolean flag that, when set to true, inverts the mask values. This means that areas of the mask that were originally transparent become opaque and vice versa. This option is useful when you want to quickly reverse the transparency effect of the mask without manually altering the mask data. By default, this parameter is set to false, meaning the mask is applied as is.

Compose RGBA Image From Mask Output Parameters:

rgba_image

The rgba_image output is the resulting image after the mask has been applied to the input image. This image will always be in RGBA format, meaning it will have four channels: red, green, blue, and alpha. The alpha channel is derived from the mask, and it determines the transparency of each pixel in the image. This output allows you to use the modified image in further processing or as a final product, with the mask's transparency effects seamlessly integrated.

Compose RGBA Image From Mask Usage Tips:

  • Ensure that the mask is properly aligned with the image dimensions to avoid unexpected results. If the mask and image sizes differ, the node will automatically resize the mask, but it's best to provide a mask that matches the image size for optimal quality.
  • Use the invert parameter to quickly toggle the transparency effect of the mask, which can be particularly useful when experimenting with different visual outcomes.

Compose RGBA Image From Mask Common Errors and Solutions:

ValueError: Image must have 3 (RGB) or 4 (RGBA) channels

  • Explanation: This error occurs when the input image does not have the correct number of channels. The node expects either an RGB image with three channels or an RGBA image with four channels.
  • Solution: Ensure that the input image is in the correct format with either three or four channels before passing it to the node.

Mask and Image must be the same size

  • Explanation: This error indicates that the mask and image dimensions do not match, which can lead to incorrect application of the mask.
  • Solution: Verify that the mask is either the same size as the image or allow the node to resize the mask automatically. If resizing is not desired, manually adjust the mask size to match the image dimensions before using the node.

Compose RGBA Image From Mask Related Nodes

Go back to the extension to check out more related nodes.
ComfyUI-LogicUtils
RunComfy
Copyright 2025 RunComfy. All Rights Reserved.

RunComfy is the premier ComfyUI platform, offering ComfyUI online environment and services, along with ComfyUI workflows featuring stunning visuals. RunComfy also provides AI Models, enabling artists to harness the latest AI tools to create incredible art.