smartcrop implementation in Python
Project description
smartcrop.py
smartcrop implementation in Python
smartcrop finds good crops for arbitrary images and crop sizes, based on Jonas Wagner’s smartcrop.js
Requirements
PIL or Pillow
Installation
pip2 install smartcrop
pip3 install smartcrop
or directly from GitHub:
pip install -e git+git://github.com/hhatto/smartcrop.py.git@master#egg=smartcrop
Usage
command-line tool
smartcrop.py FILE
use module
import json
import sys
import smartcrop
from PIL import Image
image = Image.open(sys.argv[1])
sc = smartcrop.SmartCrop()
result = sc.crop(image, 100, 100)
print(json.dumps(result, indent=2))
smartcrop.py is slower than smartcrop.js
$ identify images/t.jpg
images/t.jpg JPEG 3200x2403 3200x2403+0+0 8-bit DirectClass 2.066MB 0.000u 0:00.000
$ time smartcrop --width 300 --height 300 images/t.jpg
smartcrop --width 300 --height 300 images/t.jpg 0.30s user 0.11s system 100% cpu 0.414 total
$ time smartcroppy --width 300 --height 300 images/t.jpg
smartcroppy --width 300 --height 300 images/t.jpg 3.74s user 0.31s system 99% cpu 4.051 total
License
MIT
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
smartcrop-0.3.0.tar.gz
(5.8 kB
view hashes)
Built Distributions
Close
Hashes for smartcrop-0.3.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0a97a24b2501831c3e7a34a18249ee9719c66c4fdd20303097e9d0eb184d5ba1 |
|
MD5 | ebb30267ac87d0ce05c62976a92156f1 |
|
BLAKE2b-256 | 5ff4eac25543796c5f50608dc49d9f13cef08abfc77bc3c987fd52791282514a |
Close
Hashes for smartcrop-0.3.0-py2-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a43133a50fe13be2a613a9f40fb7d6539f96785dca7d06161fb47d14b4c5c3e8 |
|
MD5 | c969b601a8e8a7742925b162cd28651c |
|
BLAKE2b-256 | 721797a4ea96379671848580ae69b26ca8a0a73815ddbe01ea1511b3cc9d7000 |