Practical overview
When it fits
Use Autocrop when images need face-centered framing, especially for profile-picture or ID-card preparation. Choose the Python interface to incorporate cropping into a Python workflow, or the command-line tool for file-based processing and shell-composed batches.
Who it is for
- Developers building image-processing workflows in Python
- People preparing profile pictures or ID-card photos in batches
- Command-line users who want consistent face-centered crops
Documented uses
- Center a crop around the largest face in a picture.
- Set crop dimensions or adjust the face’s proportion within the output.
- Pass image data into a Python workflow and receive an RGB or RGBA NumPy array.
- Use shell tools to process selected images from a directory.
Requirements & limits
- The detector centers the crop on the largest face it finds.
- The command-line tool processes one image per invocation; folder workflows require shell composition.
- Command-line width and height default to 500 pixels, with options to set dimensions or retain original crop pixels.
- The Python crop method returns
Nonewhen no face is detected. - For animated GIFs, only the first frame is used.
Check current requirements in the official documentation. Source-based guidance does not mean OpenViST has run or independently tested this project.
Batch-crop JPG and PNG images with shell tools
Process selected JPG and PNG files one at a time and save face-centered crops in a separate directory.
Before you start
- Python with Autocrop installed using
pip install autocrop - A shell environment with
find - Input images stored under a
picsdirectory
Steps
Create a
cropoutput directory.Use
findto select JPG and PNG files underpics.For each file, create its corresponding output subdirectory and send the image to Autocrop.
Write the cropped image bytes to the matching path under
crop.
Expected outcome
A separate directory tree of cropped outputs corresponding to the selected input images.
Guide limitations
- Autocrop handles one image per invocation; the shell loop provides the batch workflow.
- The documented example covers JPG and PNG inputs.
Crop one image in Python and save it when a face is found
Use the Python API to crop a portrait image and save the result only when a crop is returned.
Before you start
- Python with Autocrop installed using
pip install autocrop - Pillow for saving the returned NumPy array
- A portrait image such as
portrait.png
Steps
Import
Cropperfromautocropand create a cropper instance.Pass the image filepath to
cropper.crop().If the returned array is not
None, convert it to a Pillow image and save it.
Expected outcome
A saved cropped image when a face is detected.
Guide limitations
- The documented example saves output only when the crop method returns an array.
- The Python method also accepts OpenCV-style BGR/BGRA NumPy arrays and returns RGB/RGBA NumPy arrays.
Sources & review
Source record details
- Source availability
- Active
- Sources checked
- 17 October 2026
- Original website title
- leblancfg/autocrop · Official homepage title · retained in its source language

