ComfyUI  >  Nodes  >  Masquerade Nodes >  Paste By Mask

ComfyUI Node: Paste By Mask

Class Name

Paste By Mask

Category
Masquerade Nodes
Author
BadCafeCode (Account age: 485 days)
Extension
Masquerade Nodes
Latest Updated
6/19/2024
Github Stars
0.3K

How to Install Masquerade Nodes

Install this extension via the ComfyUI Manager by searching for  Masquerade Nodes
  • 1. Click the Manager button in the main menu
  • 2. Select Custom Nodes Manager button
  • 3. Enter Masquerade 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
  • High-speed GPU machines
  • 200+ preloaded models/nodes
  • Freedom to upload custom models/nodes
  • 50+ ready-to-run workflows
  • 100% private workspace with up to 200GB storage
  • Dedicated Support

Run ComfyUI Online

Paste By Mask Description

Overlay images with precision using masks for targeted modifications and resizing control.

Paste By Mask:

The Paste By Mask node allows you to seamlessly overlay one image onto another using a mask to determine the exact placement and blending of the images. This node is particularly useful for creating composite images where specific parts of an image need to be replaced or enhanced with another image. By using a mask, you can control which areas of the base image are affected, ensuring precise and targeted modifications. The node also offers various resizing behaviors to ensure that the pasted image fits perfectly within the masked area, providing flexibility and control over the final output.

Paste By Mask Input Parameters:

image_base

This parameter represents the base image onto which another image will be pasted. It serves as the canvas for the operation, and the mask will determine which parts of this image will be replaced or blended with the image to paste.

image_to_paste

This parameter is the image that will be overlaid onto the base image. The areas where this image will appear are determined by the mask. The image can be resized according to the specified resize behavior to fit the masked area appropriately.

mask

The mask is an image that defines the regions of the base image that will be affected by the paste operation. The mask uses its alpha channel to determine the transparency and blending of the pasted image, allowing for smooth transitions and precise control over the composite result.

resize_behavior

This parameter controls how the image to paste is resized to fit the masked area. The available options are:

  • resize: Resizes the image to fit the mask exactly.
  • keep_ratio_fill: Maintains the aspect ratio of the image to paste while filling the masked area, potentially extending outside the mask.
  • keep_ratio_fit: Maintains the aspect ratio of the image to paste while fitting within the masked area.
  • source_size: Uses the original size of the image to paste without resizing.
  • source_size_unmasked: Uses the original size of the image to paste without resizing, but only for unmasked areas.

mask_mapping_optional

This optional parameter, if provided, controls which image gets pasted onto which base image. It is typically obtained from a Separate Mask Components node and allows for more complex and targeted pasting operations.

Paste By Mask Output Parameters:

IMAGE

The output is a single composite image that results from pasting the image_to_paste onto the image_base using the specified mask and resize_behavior. The output image reflects the combined visual elements of both input images, blended according to the mask's transparency and the chosen resizing method.

Paste By Mask Usage Tips:

  • Use a high-contrast mask to ensure clear and precise blending between the base image and the image to paste.
  • Experiment with different resize_behavior options to achieve the desired fit and aspect ratio for the pasted image.
  • Utilize the mask_mapping_optional parameter for advanced compositing tasks where multiple images need to be pasted onto different regions of the base image.

Paste By Mask Common Errors and Solutions:

"Mask dimensions do not match base image dimensions"

  • Explanation: This error occurs when the dimensions of the mask do not match the dimensions of the base image.
  • Solution: Ensure that the mask image has the same width and height as the base image before performing the paste operation.

"Invalid resize behavior option"

  • Explanation: This error occurs when an unsupported value is provided for the resize_behavior parameter.
  • Solution: Verify that the resize_behavior parameter is set to one of the supported options: resize, keep_ratio_fill, keep_ratio_fit, source_size, or source_size_unmasked.

"Image to paste dimensions are incompatible"

  • Explanation: This error occurs when the dimensions of the image to paste are not compatible with the specified resize behavior.
  • Solution: Adjust the dimensions of the image to paste or choose a different resize_behavior option to ensure compatibility.

Paste By Mask Related Nodes

Go back to the extension to check out more related nodes.
Masquerade Nodes
RunComfy

© Copyright 2024 RunComfy. All Rights Reserved.

RunComfy is the premier ComfyUI platform, offering ComfyUI online environment and services, along with ComfyUI workflows featuring stunning visuals.