ComfyUI > Nodes > ComfyUI-YCNodes > MaskCrop_YC

ComfyUI Node: MaskCrop_YC

Class Name

MaskCrop_YC

Category
YCNode/Mask
Author
yichengup (Account age: 473days)
Extension
ComfyUI-YCNodes
Latest Updated
2025-06-03
Github Stars
0.02K

How to Install ComfyUI-YCNodes

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

MaskCrop_YC Description

Facilitates precise image cropping using masks for focused image processing tasks, maintaining image quality and integrity seamlessly.

MaskCrop_YC:

The MaskCrop_YC node is designed to facilitate the cropping of images using a mask, which is particularly useful in image processing tasks where specific regions of an image need to be isolated or highlighted. This node allows you to define a mask that specifies the area of the image to be cropped, providing a precise and efficient way to focus on particular sections of an image. The primary benefit of using this node is its ability to handle images and masks in a seamless manner, ensuring that the cropped output maintains the integrity and quality of the original image. By leveraging this node, you can streamline workflows that require image segmentation or focus on specific image areas, making it an essential tool for AI artists and designers who need to manipulate images with precision.

MaskCrop_YC Input Parameters:

background_image

The background_image parameter is required and represents the original image from which a section will be cropped. This parameter is crucial as it serves as the base image that the mask will be applied to, ensuring that the correct area is isolated for further processing. There are no specific minimum or maximum values for this parameter, as it depends on the image size and resolution you are working with.

cropped_image

The cropped_image parameter is also required and refers to the image that has been previously cropped. This parameter is used to align the mask with the correct section of the original image, ensuring that the cropping process is accurate and effective. Like the background_image, this parameter does not have specific value constraints but should match the dimensions of the area you intend to crop.

crop_coords

The crop_coords parameter is required and specifies the coordinates of the cropping area within the image. This parameter is essential for defining the exact section of the image to be cropped, allowing for precise control over the cropping process. The coordinates should be provided in a format that the node can interpret, typically as a tuple of values representing the top-left and bottom-right corners of the cropping area.

invert_mask

The invert_mask parameter is optional and is a boolean value that determines whether the mask should be inverted. By default, this parameter is set to False, meaning the mask will be applied as is. If set to True, the mask will be inverted, which can be useful in scenarios where you want to exclude the masked area instead of including it. This parameter provides flexibility in how the mask is applied to the image.

cropped_mask

The cropped_mask parameter is optional and allows you to provide a specific mask to be used during the cropping process. This mask defines the area of the image to be retained, offering an additional layer of control over the cropping operation. If not provided, the node will attempt to use the crop_frame or create a default mask.

crop_frame

The crop_frame parameter is optional and serves as an alternative mask if the cropped_mask is not provided. This parameter can be used to define the cropping area, ensuring that the correct section of the image is isolated. If neither cropped_mask nor crop_frame is provided, the node will create a default mask that selects the entire cropping area.

MaskCrop_YC Output Parameters:

cropped_image

The cropped_image output parameter provides the resulting image after the cropping operation has been applied. This image represents the section of the original image that was isolated using the mask, allowing you to focus on specific areas of interest. The cropped image maintains the quality and resolution of the original, ensuring that it can be used for further processing or analysis.

cropped_mask

The cropped_mask output parameter returns the mask that was used during the cropping process. This mask can be useful for verifying the accuracy of the cropping operation or for use in subsequent image processing tasks. It provides a visual representation of the area that was isolated from the original image.

crop_frame

The crop_frame output parameter provides a preview of the cropping area, allowing you to visualize the section of the image that was isolated. This output is particularly useful for confirming that the correct area was cropped and can be used to make adjustments if necessary.

crop_frame_preview

The crop_frame_preview output parameter offers a preview of the cropping frame, providing a quick way to assess the results of the cropping operation. This preview can be used to ensure that the cropping process was successful and that the desired area of the image was isolated.

crop_coords

The crop_coords output parameter returns the coordinates of the cropping area, allowing you to verify the exact section of the image that was isolated. This output is useful for documentation purposes or for use in further image processing tasks where precise coordinates are required.

MaskCrop_YC Usage Tips:

  • Ensure that the background_image and cropped_image parameters are correctly aligned to achieve accurate cropping results.
  • Use the invert_mask parameter to experiment with different masking effects, such as excluding certain areas of the image.
  • Verify the crop_coords to ensure that the correct section of the image is being isolated, especially when working with complex images.

MaskCrop_YC Common Errors and Solutions:

Mask dimensions mismatch

  • Explanation: This error occurs when the dimensions of the mask do not match the dimensions of the image being cropped.
  • Solution: Ensure that the mask and image dimensions are compatible, and adjust the mask size if necessary to match the image.

Invalid crop coordinates

  • Explanation: This error arises when the provided crop coordinates are outside the bounds of the image.
  • Solution: Double-check the crop_coords to ensure they are within the image boundaries and adjust them accordingly.

Mask too small

  • Explanation: This error happens when the mask dimensions are too small, potentially due to incorrect scaling or resolution settings.
  • Solution: Verify the mask size and ensure it is large enough to cover the desired cropping area, adjusting the resolution if needed.

MaskCrop_YC Related Nodes

Go back to the extension to check out more related nodes.
ComfyUI-YCNodes
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.