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
numpy for smartcrop_numpy.py (see https://github.com/smartcrop/smartcrop.py/issues/12)
Installation
pip3 install smartcrop
pip3 install numpy # if you want to use smartcrop_numpy.py
or directly from GitHub:
pip install -e git+git://github.com/hhatto/smartcrop.py.git@master#egg=smartcrop
Usage
Use the basic command-line tool:
$ smartcroppy --help
usage: smartcroppy [-h] [--debug] [--width WIDTH] [--height HEIGHT]
INPUT_FILE OUTPUT_FILE
positional arguments:
INPUT_FILE input image file
OUTPUT_FILE output image file
optional arguments:
-h, --help show this help message and exit
--debug debug mode
--width WIDTH crop width
--height HEIGHT crop height
Processing an image:
smartcroppy --width 300 --height 300 tests/images/business-work-1.jpg output.jpg
Or use the module it in your code (this is a really basic example):
import json
import sys
import smartcrop # or smartcrop_numpy
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))
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file smartcrop-0.3.1.tar.gz.
File metadata
- Download URL: smartcrop-0.3.1.tar.gz
- Upload date:
- Size: 5.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/46.1.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f9c94d5febb0ac9a68dc623856438a1ca96fa26814974420ac5771b1a599ff8f
|
|
| MD5 |
3528faa25a73f64d45159c357f920ba5
|
|
| BLAKE2b-256 |
f45e4de74c05ef9de25501f780de1471692224d04c81b0b5db56d5d0945e645d
|
File details
Details for the file smartcrop-0.3.1-py3-none-any.whl.
File metadata
- Download URL: smartcrop-0.3.1-py3-none-any.whl
- Upload date:
- Size: 7.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/46.1.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c543f308e85c0d5c42303155f1a2c94d9f88f3e5535ff1dab92f0f306d0de714
|
|
| MD5 |
75a8c4e4a75574004452fd74ca6343fd
|
|
| BLAKE2b-256 |
3677d24e937e058468724214fbab972a000d670a04d062f9e887caf169461661
|