ComfyUI > Nodes > ComfyUI-UniversalToolkit > Image Crop By Mask And Resize (UTK)

ComfyUI Node: Image Crop By Mask And Resize (UTK)

Class Name

ImageCropByMaskAndResize_UTK

Category
UniversalToolkit/Image
Author
whmc76 (Account age: 1110days)
Extension
ComfyUI-UniversalToolkit
Latest Updated
2026-03-16
Github Stars
0.07K

How to Install ComfyUI-UniversalToolkit

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

Image Crop By Mask And Resize (UTK) Description

Crops and resizes images using masks, supports batch processing, and ensures AI-friendly dimensions.

Image Crop By Mask And Resize (UTK):

The ImageCropByMaskAndResize_UTK node is designed to streamline the process of cropping images based on mask detection and resizing them to a specified resolution. This node is particularly beneficial for batch processing, ensuring that all images and masks are processed uniformly. It employs a three-stage approach: analyzing masks to determine optimal crop regions, calculating unified dimensions for consistent output, and cropping and resizing images accordingly. The node supports various resizing methods, such as fill, crop, letterbox, and stretch, allowing you to choose the best fit for your needs. Additionally, it ensures that the output dimensions are AI-friendly by aligning them to 16-pixel multiples. This node is ideal for AI artists who need to prepare images for further processing or analysis, offering flexibility in handling aspect ratios and upscaling quality.

Image Crop By Mask And Resize (UTK) Input Parameters:

base_resolution

The base_resolution parameter sets the target resolution for the longer side of the image. This parameter determines the scale at which the image will be resized, ensuring that the longer side matches the specified resolution while maintaining the aspect ratio. It is crucial for defining the final size of the output image and should be chosen based on the desired output quality and use case.

padding

The padding parameter adds extra space around the detected crop regions. This can be useful for ensuring that important parts of the image are not cut off during cropping. The padding value is added to all sides of the detected region, providing a buffer zone that can help maintain context or prevent clipping of essential details.

min/max_crop_resolution

These parameters define the constraints for the crop region size. The min_crop_resolution ensures that the crop region is not smaller than a specified size, while the max_crop_resolution prevents it from exceeding a certain size. These constraints help maintain consistency across different images and prevent overly small or large crop regions that could affect the quality or usability of the output.

resize_method

The resize_method parameter determines how the aspect ratio is handled during resizing. Options include fill, crop, letterbox, and stretch. Each method offers a different approach to resizing, such as filling the target size completely, fitting within the target size with padding, or stretching to fit, which may distort the aspect ratio. Choosing the right method depends on the desired outcome and the importance of maintaining the original aspect ratio.

upscale_method

The upscale_method parameter specifies the interpolation method used for high-quality scaling. Options include nearest, bilinear, bicubic, and Lanczos. Each method offers a different balance between speed and quality, with Lanczos providing the highest quality at the cost of processing time. Selecting the appropriate method depends on the quality requirements and processing constraints of your project.

Image Crop By Mask And Resize (UTK) Output Parameters:

images

The images output parameter provides the processed images after cropping and resizing. These images are ready for further use or analysis, having been adjusted to the specified dimensions and aspect ratio. This output is crucial for ensuring that all images in a batch are consistent and meet the desired specifications.

masks

The masks output parameter contains the processed masks corresponding to the cropped and resized images. These masks are essential for applications that require precise region detection or segmentation, as they maintain alignment with the processed images.

bbox

The bbox output parameter provides the bounding box coordinates for the crop regions. This information is useful for understanding the spatial relationship between the original and processed images, allowing for further analysis or adjustments if needed.

Image Crop By Mask And Resize (UTK) Usage Tips:

  • To maintain the original aspect ratio while resizing, consider using the letterbox method, which adds black bars to fit the target size without distortion.
  • For high-quality upscaling, use the Lanczos interpolation method, especially when image quality is a priority over processing speed.
  • Adjust the padding parameter to ensure that important details near the edges of the crop region are not lost during processing.

Image Crop By Mask And Resize (UTK) Common Errors and Solutions:

Masked area out of bounds

  • Explanation: This error occurs when the detected crop region exceeds the boundaries of the original image.
  • Solution: Ensure that the mask accurately represents the area to be cropped and adjust the min/max_crop_resolution parameters to prevent out-of-bounds errors.

Multiple mask inputs, using the first

  • Explanation: This warning indicates that multiple masks were provided, but only the first one is being used for processing.
  • Solution: Verify that the correct mask is being used and consider splitting the batch if multiple masks need to be processed separately.

Image Crop By Mask And Resize (UTK) Related Nodes

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

Image Crop By Mask And Resize (UTK)