ComfyUI > Nodes > Bjornulf_custom_nodes > 🖼+🖼 Stack two images (Background+Overlay alpha)

ComfyUI Node: 🖼+🖼 Stack two images (Background+Overlay alpha)

Class Name

Bjornulf_CombineBackgroundOverlay

Category
Bjornulf
Author
justUmen (Account age: 3046days)
Extension
Bjornulf_custom_nodes
Latest Updated
2025-02-28
Github Stars
0.2K

How to Install Bjornulf_custom_nodes

Install this extension via the ComfyUI Manager by searching for Bjornulf_custom_nodes
  • 1. Click the Manager button in the main menu
  • 2. Select Custom Nodes Manager button
  • 3. Enter Bjornulf_custom_nodes 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

🖼+🖼 Stack two images (Background+Overlay alpha) Description

Blend overlay onto background image with mask for precise composition in AI art.

🖼+🖼 Stack two images (Background+Overlay alpha):

The Bjornulf_CombineBackgroundOverlay node is designed to seamlessly blend an overlay image onto a background image using a specified mask to define transparency levels. This node is particularly useful for AI artists who want to create composite images by layering different visual elements with precision. By converting images from torch tensors to numpy arrays and then to PIL images, it allows for detailed manipulation of image data. The node calculates the exact position for the overlay based on user-defined horizontal and vertical percentages, ensuring that the overlay is placed exactly where desired on the background. This process results in a new image that combines the background and overlay with the mask applied, providing a powerful tool for creating complex visual compositions.

🖼+🖼 Stack two images (Background+Overlay alpha) Input Parameters:

background

The background parameter is an image that serves as the base layer onto which the overlay will be applied. It is expected to be in the form of a torch tensor, which is then converted to a numpy array for processing. This parameter is crucial as it defines the canvas size and the primary visual context for the overlay.

overlay

The overlay parameter is the image that will be placed on top of the background. Like the background, it is initially a torch tensor and is converted to a numpy array. The overlay image is combined with the mask to create transparency effects, allowing for intricate layering and blending with the background.

mask

The mask parameter is used to define the transparency levels of the overlay image. It is also a torch tensor converted to a numpy array, and it determines which parts of the overlay are visible and which are transparent. This parameter is essential for achieving smooth transitions and realistic blending between the overlay and the background.

horizontal_position

The horizontal_position parameter is a float that specifies the horizontal placement of the overlay on the background as a percentage. The default value is 50, with a range from -50 to 150, allowing for flexible positioning beyond the edges of the background. This parameter helps in aligning the overlay precisely on the horizontal axis.

vertical_position

The vertical_position parameter is a float that determines the vertical placement of the overlay on the background as a percentage. It also defaults to 50 and ranges from -50 to 150, providing the ability to position the overlay above or below the visible area of the background. This parameter is key for vertical alignment of the overlay.

🖼+🖼 Stack two images (Background+Overlay alpha) Output Parameters:

IMAGE

The output parameter is an IMAGE, which is the final composite image resulting from the combination of the background and overlay with the mask applied. This image is returned as a torch tensor, ready for further processing or saving. The output image retains the dimensions of the background and incorporates the overlay with the specified transparency and positioning, making it a versatile result for various artistic applications.

🖼+🖼 Stack two images (Background+Overlay alpha) Usage Tips:

  • To achieve precise overlay placement, adjust the horizontal_position and vertical_position parameters carefully, considering the dimensions of both the background and overlay images.
  • Use a well-defined mask to control the transparency of the overlay effectively, ensuring that the blending between the overlay and background appears natural and seamless.

🖼+🖼 Stack two images (Background+Overlay alpha) Common Errors and Solutions:

Error: "Image size mismatch"

  • Explanation: This error occurs when the dimensions of the overlay do not match the expected size relative to the background.
  • Solution: Ensure that the overlay image is appropriately sized or resized to fit within the background dimensions before processing.

Error: "Invalid mask format"

  • Explanation: This error indicates that the mask provided is not in the correct format or does not match the overlay dimensions.
  • Solution: Verify that the mask is a valid torch tensor and that its dimensions align with those of the overlay image.

🖼+🖼 Stack two images (Background+Overlay alpha) Related Nodes

Go back to the extension to check out more related nodes.
Bjornulf_custom_nodes
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 Playground, enabling artists to harness the latest AI tools to create incredible art.