ComfyUI > Nodes > ComfyUI_pytorch360convert > Crop Image with Coords

ComfyUI Node: Crop Image with Coords

Class Name

Crop Image with Coords

Category
pytorch360convert/miscellaneous
Author
ProGamerGov (Account age: 4100days)
Extension
ComfyUI_pytorch360convert
Latest Updated
2025-09-22
Github Stars
0.03K

How to Install ComfyUI_pytorch360convert

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

The node crops images precisely using specified start and end coordinates for focused manipulation.

Crop Image with Coords:

The Crop Image with Coords node is designed to facilitate precise image manipulation by allowing you to crop a specific section of an image based on defined coordinates. This node is particularly useful for tasks that require focusing on a particular area of an image, such as enhancing details or isolating a subject. By providing the ability to specify both starting and ending coordinates for the crop, this node offers flexibility in selecting the exact portion of the image you wish to work with. This capability is essential for applications in image processing where precision is key, such as in data augmentation, image analysis, or artistic transformations. The node ensures that the cropped section is accurately extracted, maintaining the integrity of the image data within the specified bounds.

Crop Image with Coords Input Parameters:

image

The image parameter is the input image that you want to crop. It should be a 4-dimensional tensor, typically representing a batch of images with dimensions corresponding to batch size, height, width, and channels. This parameter is crucial as it provides the source material from which the crop will be extracted. There are no specific minimum or maximum values for this parameter, but it must conform to the expected tensor shape.

crop_h

The crop_h parameter specifies the starting height coordinate for the crop. It determines the vertical position from which the cropping will begin. The default value is 0, meaning the crop will start from the top of the image unless otherwise specified. This parameter allows you to control the vertical positioning of the crop, ensuring that you can focus on the desired section of the image.

crop_w

The crop_w parameter defines the starting width coordinate for the crop. Similar to crop_h, it sets the horizontal position from which the cropping will commence. The default value is 0, indicating that the crop will start from the left edge of the image unless adjusted. This parameter is essential for horizontally aligning the crop to capture the intended area.

crop_h2

The crop_h2 parameter indicates the ending height coordinate for the crop. If set to a value less than 1, the node will calculate the end position based on the specified crop height, centering the crop vertically. The default value is -1, which triggers this automatic calculation. This parameter provides flexibility in defining the vertical extent of the crop, allowing for both fixed and dynamic cropping based on image dimensions.

crop_w2

The crop_w2 parameter specifies the ending width coordinate for the crop. Like crop_h2, if set to a value less than 1, the node will automatically determine the end position based on the specified crop width, centering the crop horizontally. The default value is -1, enabling this automatic adjustment. This parameter is crucial for defining the horizontal extent of the crop, offering both fixed and adaptive cropping options.

Crop Image with Coords Output Parameters:

Cropped Image

The Cropped Image output is the section of the original image that has been extracted based on the specified coordinates. This output is a 4-dimensional tensor, maintaining the same batch and channel dimensions as the input image but with reduced height and width according to the crop parameters. This output is essential for further processing or analysis, as it isolates the area of interest from the original image.

Coords

The Coords output is a list of integers representing the coordinates used for cropping: [start_h, end_h, start_w, end_w]. This output provides a record of the exact cropping parameters applied, which can be useful for documentation, reproducibility, or further processing steps that require knowledge of the cropped region's location within the original image.

Crop Image with Coords Usage Tips:

  • Ensure that the image input is a 4-dimensional tensor to avoid dimension-related errors during processing.
  • Use crop_h2 and crop_w2 set to -1 for automatic centering of the crop if you want to focus on the central part of the image without manually calculating coordinates.
  • Adjust crop_h and crop_w to target specific areas of the image, such as a subject or region of interest, for more focused image manipulation.

Crop Image with Coords Common Errors and Solutions:

"image should have 4 dimensions, got X"

  • Explanation: This error occurs when the input image does not have the expected 4-dimensional shape.
  • Solution: Ensure that the input image is a 4-dimensional tensor, typically with dimensions corresponding to batch size, height, width, and channels.

"IndexError: index out of bounds"

  • Explanation: This error may occur if the specified crop coordinates exceed the dimensions of the input image.
  • Solution: Verify that the crop_h, crop_w, crop_h2, and crop_w2 parameters are within the bounds of the image dimensions. Adjust them to ensure they do not exceed the image's height and width.

Crop Image with Coords Related Nodes

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