Giter VIP home page Giter VIP logo

autocrop's Introduction

autocrop

Travis Build Status AppVeyor Build Status Codecov master PyPI version Downloads Language grade: Python

Perfect for profile picture processing for your website or batch work for ID cards, autocrop will output images centered around the biggest face detected.

Use

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
  -r, --reject
		Folder where images without detected faces will be placed.
		Default: same as output 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

Examples

  • Crop every image in the pics folder, resize them to 400 px squares, and output them in the crop directory:
    • autocrop -i pics -o crop -w 400 -H 400.
    • Images where a face can't be detected will be left in crop.
  • Same as above, but output the images with undetected faces to the reject folder:
    • autocrop -i pics -o crop -r nofaces -w 400 -H 400.
  • Same as the first example, but add more padding at the bottom:
    • autocrop -i pics -o crop -w 400 -H 400 --facePercent 50 --padUp 20 --padDown 50.

If no output folder is added, asks for confirmation and destructively crops images in-place.

Supported file types

The following file types are supported:

  • EPS files (.eps)
  • GIF files (.gif) (only the first frame of an animated GIF is used)
  • JPEG 2000 files (.j2k, .j2p, .jp2, .jpx)
  • JPEG files (.jpeg, .jpg, .jpe)
  • LabEye IM files (.im)
  • macOS ICNS files (.icns)
  • Microsoft Paint bitmap files (.msp)
  • PCX files (.pcx)
  • Portable Network Graphics (.png)
  • Portable Pixmap files (.pbm, .pgm, .ppm)
  • SGI files (.sgi)
  • SPIDER files (.spi)
  • TGA files (.tga)
  • TIFF files (.tif, .tiff)
  • WebP (.webp)
  • Windows bitmap files (.bmp, .dib)
  • Windows ICO files (.ico)
  • X bitmap files (.xbm)

Installation

Simple! In your command line, type:

pip install autocrop

Gotchas

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.

Installing directly

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 .

conda

Development of a conda-forge package for the Anaconda Python distribution is also currently slated for development. Please leave feedback on issue #7 if you are insterested in helping out.

Requirements

Best practice for your projects is of course to use virtual environments. At the very least, you will need to have pip installed.

Autocrop is currently being tested on:

  • Python:
    • 2.7
    • 3.4
    • 3.5
    • 3.6
  • OS:
    • Linux
    • macOS
    • Windows

More Info

Check out:

Adapted from:

Contributing

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.

autocrop's People

Contributors

leblancfg avatar sirnarsh avatar ninjajc01 avatar jcheong0428 avatar nomicode avatar szrudi avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.