Perfect for profile picture processing for your website or batch work for ID cards, autocrop will output images centered around the biggest face detected.
From the command line:
usage: [-h] [-o OUTPUT] [-i INPUT] [-w WIDTH] [-H HEIGHT] [-v] Automatically crops faces from batches of pictures optional arguments: -h, --help Show this help message and exit -o, --output, -p, --path Folder where cropped images will be placed. Default: current working directory -i, --input Folder where images to crop are located. Default: current working directory -w, --width Width of cropped files in px. Default=500 -H, --height Height of cropped files in px. Default=500 --facePercent Percentage of Face height to image height (zoom factor) --padUp Padding up value compared to padDown. Default=50 --padDown Padding down value compared to padDown. Default=50 --padLeft Padding left value compared to padRight. Default=50 --padRight Padding right value compared to padLeft. Default=50 -v, --version Show program's version number and exit
Params (width, height, facePercent)
autocrop -i pics -o crop -w 400 -H 400 --facePercent 50.
- Example more padding down:
autocrop -i pics -o crop -w 400 -H 400 --facePercent 50 --padUp 20 --padDown 50.
What it does
The previous command will:
- Copy all images found in the top level of
- Crop around the face and resize to 400x400 pixels all images in
Images where a face can't be detected will be left in
If no output folder is added, asks for confirmation and destructively crops images in-place.
Simple! In your command line, type:
pip install autocrop
Autocrop uses OpenCV to perform face detection, which is installed through binary wheels. If you already have OpenCV 3+ installed, you may wish to uninstall the additional OpenCV installation:
pip uninstall opencv-python.
In some cases, you may wish the package directly, instead of through PyPI:
cd ~ git clone https://github.com/leblancfg/autocrop cd autocrop pip install .
Autocrop is currently being tested on:
Although autocrop is essentially a CLI wrapper around a single OpenCV function, it is actively developed. It has active users throughout the world.
If you would like to contribute, please consult the contribution docs.