Skip to content

A python package to crop smaller photos out of a larger image and optionally rotate crooked photos

License

Notifications You must be signed in to change notification settings

msaavedra/autocrop

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

60 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This is a python package to crop smaller photos out of a larger image and
optionally rotate crooked photos.  The typical use would be to scan several
photos in a flatbed scanner, and use autocrop to find the photos, deskew them,
and save them independently.

Pipenv can be used to install dependencies (currently only pillow and numpy).

Basic usage of the package is as follows:

>>> from PIL import Image
>>> from autocrop import MultiPartImage, Background
>>> 
>>> # A saved scan with the scanner empty.
>>> blank_img = Image.open('/path/to/blank/scan')
>>> background = Background().load_from_image(blank_img, dpi=200)
>>> 
>>> # A saved scan with multiple photos loaded in the scanner
>>> scan_img = Image.open('/path/to/scanned/image')
>>> scan = MultiPartImage(scan_img, background, dpi=200)
>>> 
>>> for index, photo in enumerate(scan):
...     photo.save('/path/to/cropped/image-%d.jpg' % index)

Also included is a simple linux command-line script to initiate a scan and
handle the cropping.  It should be considered a demonstration of most of the
capabilities of the package, not a utility for general wide-spread use.

About

A python package to crop smaller photos out of a larger image and optionally rotate crooked photos

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors 4

  •  
  •  
  •  
  •