ComfyUI > Nodes > ComfyUI-YCNodes_Toolkit > Load Image Crop Expand

ComfyUI Node: Load Image Crop Expand

Class Name

ycImageCrop

Category
YCNode/utils
Author
yichengup (Account age: 774days)
Extension
ComfyUI-YCNodes_Toolkit
Latest Updated
2026-03-23
Github Stars
0.05K

How to Install ComfyUI-YCNodes_Toolkit

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

Load Image Crop Expand Description

Facilitates image cropping with size, position, color fill options, and base64 support.

Load Image Crop Expand:

The ycImageCrop node is designed to facilitate the cropping of images with added flexibility and customization options. It allows you to crop an image to a specified size and position, while also providing the ability to fill the extended areas with a specified color if the crop region extends beyond the original image boundaries. This node is particularly useful for AI artists who need to manipulate images by focusing on specific areas or adjusting the aspect ratio without losing important content. By offering a mask output, it also supports further image processing tasks where distinguishing between the cropped and extended areas is necessary. The node's ability to handle images encoded in base64 format makes it versatile for various applications, including web-based image processing.

Load Image Crop Expand Input Parameters:

image_base64

This parameter accepts a base64-encoded string representing the image you wish to crop. It allows you to input images directly from encoded data, which is particularly useful for web applications or when dealing with image data in text format. The default value is an empty string, and it should be a valid base64 string to avoid errors.

crop_x

This integer parameter specifies the x-coordinate of the top-left corner of the crop area. It determines the horizontal starting point of the crop within the image. The value can range from -4096 to 4096, with a default of 0. Negative values allow cropping to extend beyond the left edge of the image, filling the area with the specified fill color.

crop_y

Similar to crop_x, this integer parameter defines the y-coordinate of the top-left corner of the crop area, setting the vertical starting point. It also ranges from -4096 to 4096, with a default of 0, allowing for cropping beyond the top edge of the image.

crop_width

This parameter sets the width of the crop area in pixels. It determines how wide the cropped section will be. The value can range from 1 to 8192, with a default of 512. Adjusting this value allows you to control the horizontal size of the cropped image.

crop_height

This parameter specifies the height of the crop area in pixels, controlling the vertical size of the cropped section. It ranges from 1 to 8192, with a default of 512, allowing you to tailor the crop to your desired dimensions.

aspect_ratio

This string parameter allows you to maintain a specific aspect ratio during cropping. The default value is "free", meaning no aspect ratio is enforced. You can specify other ratios to ensure the cropped image maintains a particular width-to-height relationship.

fill_color

This parameter defines the color used to fill areas of the crop that extend beyond the original image boundaries. It accepts both hexadecimal color codes (e.g., #RRGGBB) and RGB values (e.g., 255,255,255). The default is #000000 (black). This feature is useful for maintaining a consistent background when cropping extends beyond the image.

Load Image Crop Expand Output Parameters:

image

This output provides the cropped image as a tensor, including any filled areas if the crop extends beyond the original image boundaries. It is the primary result of the cropping operation, ready for further processing or display.

mask

The mask output is a tensor that indicates which parts of the output image are original and which are filled. A value of 0 represents original image areas, while 1 indicates filled regions. This is useful for distinguishing between cropped and extended areas in subsequent processing steps.

width

This output returns the width of the cropped image, reflecting the crop_width parameter value. It confirms the horizontal size of the resulting image.

height

This output provides the height of the cropped image, corresponding to the crop_height parameter value. It confirms the vertical size of the resulting image.

Load Image Crop Expand Usage Tips:

  • Ensure your image_base64 input is correctly formatted and valid to avoid errors during decoding.
  • Use negative values for crop_x and crop_y if you want to include areas outside the original image, which will be filled with the specified fill_color.
  • Adjust crop_width and crop_height to focus on specific areas of interest within the image, ensuring the dimensions fit your needs.
  • Utilize the aspect_ratio parameter to maintain consistent proportions, especially when preparing images for specific display formats.

Load Image Crop Expand Common Errors and Solutions:

Error loading image from base64

  • Explanation: This error occurs when the base64 string provided is invalid or improperly formatted, preventing successful decoding.
  • Solution: Verify that the image_base64 string is correctly encoded and does not contain extraneous characters or spaces. Ensure it is a valid base64 representation of an image.

Invalid fill color format

  • Explanation: This error arises when the fill_color parameter is not in a recognized format, such as an incorrect hexadecimal code or RGB value.
  • Solution: Check that the fill_color is specified as a valid hexadecimal color code (e.g., #RRGGBB) or as a comma-separated RGB value (e.g., 255,255,255).

Load Image Crop Expand Related Nodes

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