smartcrop implementation in Python
Project description
.. image:: https://travis-ci.com/smartcrop/smartcrop.py.svg?branch=master
:target: https://travis-ci.com/smartcrop/smartcrop.py
smartcrop.py
============
smartcrop implementation in Python
smartcrop finds good crops for arbitrary images and crop sizes, based on Jonas Wagner's `smartcrop.js`_
.. _`smartcrop.js`: https://github.com/jwagner/smartcrop.js
.. image:: https://i.gyazo.com/c602d20e025e58f5b15180cd9a262814.jpg
:width: 50%
.. image:: https://i.gyazo.com/5fbc9026202f54b13938de621562ed3d.jpg
:width: 25%
.. image:: https://i.gyazo.com/88ee22ca9e1dd7e9eba7ea96db084e5e.jpg
:width: 50%
Requirements
------------
* PIL or Pillow
Installation
------------
.. code-block:: sh
pip install --upgrade git+https://github.com/hhatto/smartcrop.py.git
Usage
-----
command-line tool
.. code-block:: sh
smartcrop.py FILE
use module
.. code-block:: python
import sys
import json
from PIL import Image
import smartcrop
sc = smartcrop.SmartCrop()
crop_options = smartcrop.DEFAULTS
crop_options['width'] = 100
crop_options['height'] = 100
img = Image.open(sys.argv[1])
ret = sc.crop(img, crop_options)
print(json.dumps(ret, indent=2))
smartcrop.py is slower than `smartcrop.js`_
.. code-block:: sh
$ 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
:target: https://travis-ci.com/smartcrop/smartcrop.py
smartcrop.py
============
smartcrop implementation in Python
smartcrop finds good crops for arbitrary images and crop sizes, based on Jonas Wagner's `smartcrop.js`_
.. _`smartcrop.js`: https://github.com/jwagner/smartcrop.js
.. image:: https://i.gyazo.com/c602d20e025e58f5b15180cd9a262814.jpg
:width: 50%
.. image:: https://i.gyazo.com/5fbc9026202f54b13938de621562ed3d.jpg
:width: 25%
.. image:: https://i.gyazo.com/88ee22ca9e1dd7e9eba7ea96db084e5e.jpg
:width: 50%
Requirements
------------
* PIL or Pillow
Installation
------------
.. code-block:: sh
pip install --upgrade git+https://github.com/hhatto/smartcrop.py.git
Usage
-----
command-line tool
.. code-block:: sh
smartcrop.py FILE
use module
.. code-block:: python
import sys
import json
from PIL import Image
import smartcrop
sc = smartcrop.SmartCrop()
crop_options = smartcrop.DEFAULTS
crop_options['width'] = 100
crop_options['height'] = 100
img = Image.open(sys.argv[1])
ret = sc.crop(img, crop_options)
print(json.dumps(ret, indent=2))
smartcrop.py is slower than `smartcrop.js`_
.. code-block:: sh
$ 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.2.1.tar.gz
(5.7 kB
view hashes)
Built Distribution
Close
Hashes for smartcrop-0.2.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d08d63752827a073acbedf158afa19514a976bcaf48beed659226db16b302b74 |
|
MD5 | 8e3e151a6bed70279cb292fd47e3b57d |
|
BLAKE2b-256 | bd68193a7fd4ead94d94cbfb765a7da39cf0ebf05565038b2482434be62ca11f |