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_base64input is correctly formatted and valid to avoid errors during decoding. - Use negative values for
crop_xandcrop_yif you want to include areas outside the original image, which will be filled with the specifiedfill_color. - Adjust
crop_widthandcrop_heightto focus on specific areas of interest within the image, ensuring the dimensions fit your needs. - Utilize the
aspect_ratioparameter 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_base64string 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_colorparameter is not in a recognized format, such as an incorrect hexadecimal code or RGB value. - Solution: Check that the
fill_coloris specified as a valid hexadecimal color code (e.g.,#RRGGBB) or as a comma-separated RGB value (e.g.,255,255,255).
