🍒Percentage_Cropper✀百分比裁剪:
The Percentage_Cropper node is designed to crop images by a specified percentage of their width and height, allowing you to focus on the central portion of an image by trimming the edges. This node is particularly useful for AI artists who want to refine their images by removing unwanted borders or emphasizing the central content. By specifying the percentage of the image to be cropped from the horizontal and vertical dimensions, you can achieve precise control over the final composition of your artwork. The node ensures that the cropping is symmetrical, maintaining the balance and integrity of the image's central area.
🍒Percentage_Cropper✀百分比裁剪 Input Parameters:
image
The image parameter is the input image tensor that you want to crop. It should be in the format (B, H, W, C), where B is the batch size, H is the height, W is the width, and C is the number of color channels. This parameter is crucial as it serves as the base upon which the cropping operation is performed.
horizontal_percent
The horizontal_percent parameter specifies the percentage of the image's width to be cropped from each side. It is a floating-point value with a default of 10.0, a minimum of 0.0, and a maximum of 100.0. Adjusting this parameter allows you to control how much of the image's width is removed, with higher values resulting in more significant cropping.
vertical_percent
The vertical_percent parameter determines the percentage of the image's height to be cropped from the top and bottom. Like horizontal_percent, it is a floating-point value with a default of 10.0, a minimum of 0.0, and a maximum of 100.0. This parameter lets you manage the vertical cropping extent, enabling you to focus on the central vertical portion of the image.
🍒Percentage_Cropper✀百分比裁剪 Output Parameters:
IMAGE
The output is an IMAGE tensor that represents the cropped version of the input image. This tensor retains the original batch size and color channels but has reduced dimensions based on the specified cropping percentages. The output image is essential for further processing or final presentation, as it reflects the refined composition achieved through the cropping operation.
🍒Percentage_Cropper✀百分比裁剪 Usage Tips:
- To maintain the aspect ratio of the central content, use equal values for
horizontal_percentandvertical_percent. - Start with smaller percentage values to ensure you do not crop out essential parts of the image, especially when working with images that have important details near the edges.
🍒Percentage_Cropper✀百分比裁剪 Common Errors and Solutions:
"Input image tensor is not in the correct format"
- Explanation: This error occurs when the input image does not have the expected shape of (B, H, W, C).
- Solution: Ensure that your input image is a 4D tensor with the correct dimensions. If necessary, add a batch dimension using
unsqueeze.
"Cropping percentage exceeds image dimensions"
- Explanation: This error happens when the specified cropping percentages result in negative or zero dimensions for the output image.
- Solution: Verify that the
horizontal_percentandvertical_percentvalues are set to reasonable numbers that do not exceed the image's dimensions. Adjust the percentages to ensure that the cropped dimensions remain positive.
