The Face Cropper Node (MarwanFaceCropping) is a custom image processing node designed for ComfyUI. It takes an input image and crops it to a 2:3 aspect ratio, ensuring that most of the subject remains in the frame while maintaining the correct proportions.
- Automatically crops images to a 2:3 ratio.
- Maintains the maximum possible height while adjusting width.
- Handles various image sizes and shapes, including non-square images.
- Includes error handling for incorrect input shapes.
- Clone this repository:
git clone https://github.com/marawan206/ComfyUI-FaceCropper.git cd face-cropper-node - Install dependencies if needed:
pip install torch pytest
- Add the node to your ComfyUI workflow.
The node expects an input image tensor of shape (batch, height, width, channels), where:
batchis the number of images.heightremains unchanged.widthis adjusted to maintain a 2:3 ratio.
Example:
import torch
from face_cropper_node import MarwanFaceCropping
image = torch.rand(1, 1024, 1024, 3) # Example input image
node = MarwanFaceCropping()
cropped, = node.execute(image)
print(cropped.shape) # Output shape should be (1, 1024, 682, 3)To verify functionality, run:
pytest test.pyFeel free to submit issues or pull requests to improve the node.
MIT License. See LICENSE for details.