A Python script that automatically crops photos into professional headshots using face detection. Optimized for Apple Silicon (M4 Mac Mini).
- Automatic face detection using OpenCV's Haar Cascade classifier
- Professional headshot dimensions (800x1000 pixels, 4:5 aspect ratio)
- Intelligent cropping with proper padding around the face
- Processes all images in the
inputfolder automatically - Saves cropped headshots to the
outputfolder
-
Activate the virtual environment:
source venv/bin/activate -
Install dependencies (if not already installed):
pip install -r requirements.txt
- Place your photos in the
inputfolder - Run the script:
python crop_headshots.py
- Find your cropped headshots in the
outputfolder
- Each processed image will be saved as
[original_filename]_headshot.jpg - Standard headshot dimensions: 800x1000 pixels
- High quality JPEG output (95% quality)
- The script detects the largest face in each image
- If no face is detected, it will perform a center crop
- The script maintains professional headshot proportions with appropriate padding above the head and around the face