ComfyUI > Nodes > antrobots ComfyUI Nodepack > Crop Image and Mask

ComfyUI Node: Crop Image and Mask

Class Name

crop

Category
antrobots-ComfyUI-nodepack/image-handling
Author
antrobot (Account age: 3193days)
Extension
antrobots ComfyUI Nodepack
Latest Updated
2025-04-02
Github Stars
0.02K

How to Install antrobots ComfyUI Nodepack

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

Crop Image and Mask Description

Transform latent images by cropping to specified size and position for precise manipulation and analysis in machine learning models.

Crop Image and Mask:

The crop node is designed to transform latent images by cropping them to a specified size and position. This node is particularly useful in scenarios where you need to focus on a specific region of a latent image, allowing for more precise manipulation and analysis. By defining the width, height, and starting coordinates (x, y), you can extract a specific portion of the image, which can be beneficial for tasks that require attention to detail or when working with large images where only a part is of interest. The cropping operation is performed on the latent space, which is a representation used in machine learning models, ensuring that the transformation is efficient and maintains the integrity of the data.

Crop Image and Mask Input Parameters:

samples

This parameter represents the latent image data that you want to crop. It is the input on which the cropping operation will be performed. The latent data is typically a multi-dimensional array that holds the encoded information of an image.

width

This parameter specifies the width of the cropped area. It determines how wide the resulting cropped image will be. The width must be a multiple of 8, with a default value of 512, a minimum of 64, and a maximum defined by the system's maximum resolution. Adjusting the width allows you to control the horizontal size of the cropped region.

height

This parameter defines the height of the cropped area. Similar to the width, it determines the vertical size of the resulting cropped image. The height must also be a multiple of 8, with a default value of 512, a minimum of 64, and a maximum defined by the system's maximum resolution. This parameter is crucial for controlling the vertical extent of the crop.

x

This parameter sets the x-coordinate of the top-left corner of the cropping area. It determines the horizontal starting point of the crop within the latent image. The x-coordinate must be a multiple of 8, with a default value of 0, and it cannot exceed the maximum resolution. Adjusting this value allows you to shift the crop horizontally.

y

This parameter sets the y-coordinate of the top-left corner of the cropping area. It determines the vertical starting point of the crop within the latent image. The y-coordinate must be a multiple of 8, with a default value of 0, and it cannot exceed the maximum resolution. This parameter is used to shift the crop vertically.

Crop Image and Mask Output Parameters:

LATENT

The output is a cropped latent image, which is a subset of the original latent data. This cropped latent retains the same data structure as the input but is limited to the specified width and height, starting from the defined x and y coordinates. The cropped latent can be used for further processing or analysis, focusing only on the area of interest.

Crop Image and Mask Usage Tips:

  • Ensure that the width and height are set to values that are multiples of 8 to avoid errors and ensure compatibility with the latent data structure.
  • Use the x and y parameters to precisely position the crop area, especially when working with large images where only a specific region is needed.

Crop Image and Mask Common Errors and Solutions:

"IndexError: index out of bounds"

  • Explanation: This error occurs when the specified x or y coordinates, combined with the width or height, exceed the dimensions of the latent image.
  • Solution: Ensure that the x and y coordinates, along with the width and height, do not exceed the dimensions of the latent image. Adjust the parameters to fit within the image bounds.

"ValueError: width and height must be multiples of 8"

  • Explanation: The width and height parameters must be multiples of 8 due to the structure of the latent data.
  • Solution: Adjust the width and height to be multiples of 8 to comply with the latent data requirements.

Crop Image and Mask Related Nodes

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