Run ComfyUI Easily with InstaSD
Skip the complex setup. InstaSD helps creative professionals build workflows and deploy them to the world:
- One-click deployment
- Any model, any node
- Powerful GPUs for rapid iteration
Available Nodes
AILab_ImageCrop
AILab_ImageCrop Node Documentation
Overview
The AILab_ImageCrop node is designed to perform cropping operations on images within the ComfyUI environment. This node is part of the ComfyUI-RMBG plugin, which is a collection of utility nodes for image processing tasks such as image manipulation, segmentation, and background removal. The ImageCrop node specifically focuses on extracting a specified portion of an input image based on user-defined parameters, and optionally, providing the rest of the image with modifications reflecting the crop.
Functionality
The AILab_ImageCrop node allows users to:
- Crop a specific region from an input image based on width, height, and position choices.
- Define a position for cropping using various anchor points like top-left, center, etc.
- Apply offsets to fine-tune the cropping location.
- Output not only the cropped region but also a version of the remaining image, which can be zeroed out or have the crop area modified based on preferences.
Inputs
The node accepts the following inputs:
- Image: The image to be cropped, which is an
IMAGEdata type input. - Width: The desired width of the crop region in pixels. This value is clamped to the image width.
- Height: The desired height of the crop region in pixels. This value is clamped to the image height.
- X Offset: A horizontal offset value to be added to the crop position. Positive values move the crop region to the right, while negative values move it to the left.
- Y Offset: A vertical offset value to be added to the crop position. Positive values move the crop region down, while negative values move it up.
- Split: A boolean value that determines the behavior of the output. If set to
True, the output reflects the rest of the image with the crop area set to zero. IfFalse, the rest of the output image is zeroed out. - Position: The anchor position for cropping. This can be set to:
- Top-Left
- Top-Center
- Top-Right
- Right-Center
- Bottom-Right
- Bottom-Center
- Bottom-Left
- Left-Center
- Center
Outputs
The node produces the following outputs:
- Crop: The cropped region of the image as an
IMAGEdata type. - Rest: The remaining part of the image with the crop region either zeroed out or with other modifications, according to the split setting.
Usage in ComfyUI Workflows
The AILab_ImageCrop node is utilized in workflows where precise image cropping is required. It can be used in scenarios that involve:
- Preprocessing images for segmentation or analysis where only a certain part of the image is needed.
- Modifying images interactively, allowing users to preview and adjust cropping parameters.
- Preparing datasets by extracting regions of interest from larger images.
- Combining with other nodes for advanced operations like applying filters or masks only to specific sections of an image.
The node's ability to output both the cropped region and the rest of the image makes it versatile in scenarios where both outputs are needed for subsequent processing.
Features and Considerations
- Positioning Flexibility: The node provides a robust mechanism for anchoring the crop position using predefined locations, along with the ability to apply fine adjustments using offsets.
- Dual Output Capability: It can simultaneously provide both the cropped section and the modified version of the rest of the image, useful for image comparison tasks.
- Performance: The node ensures that width and height are clamped to the dimensions of the input image, avoiding potential errors due to out-of-bound crop sizes.
- Integration with ComfyUI: It integrates seamlessly with other ComfyUI nodes, enhancing workflows dealing with layered and dynamic image processing tasks.
This node is particularly useful in workflows where maintaining high-quality image data while performing complex modifications is essential, given its flexibility and powerful feature set.