OpenViSTAI · Agents · Blockchain · Crypto
Menu
Image & Video AI

Autocrop

Autocrop is a Python library and command-line tool that uses OpenCV’s YuNet face detector to crop images around the largest detected face. It supports individual images through either interface and can be composed with shell tools for folder-based processing.

Independent OpenViST project profile, based on linked sources.

Autocrop — OpenViST project profile in Image & Video AI.
OpenViST project illustration. See the linked sources for product details.
Understand the project

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.
Before you choose

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 None when 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.

Source-based practical guide

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 pics directory

Steps

  1. Create a crop output directory.

  2. Use find to select JPG and PNG files under pics.

  3. For each file, create its corresponding output subdirectory and send the image to Autocrop.

  4. 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.
Source-based practical guide

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

  1. Import Cropper from autocrop and create a cropper instance.

  2. Pass the image filepath to cropper.crop().

  3. 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.
Evidence and transparency

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