Name | smartcrop JSON |
Version |
0.4.0
JSON |
| download |
home_page | |
Summary | smartcrop implementation in Python |
upload_time | 2023-07-05 11:30:59 |
maintainer | |
docs_url | None |
author | |
requires_python | >=3.9 |
license | |
keywords |
image
crop
pil
pillow
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
|
coveralls test coverage |
No coveralls.
|
[![image](https://travis-ci.com/smartcrop/smartcrop.py.svg?branch=master)](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](https://github.com/jwagner/smartcrop.js).
![image](https://i.gyazo.com/c602d20e025e58f5b15180cd9a262814.jpg){width="50.0%"}
![image](https://i.gyazo.com/5fbc9026202f54b13938de621562ed3d.jpg){width="25.0%"}
![image](https://i.gyazo.com/88ee22ca9e1dd7e9eba7ea96db084e5e.jpg){width="50.0%"}
## Requirements
Python requirements are defined in [pyproject.toml](pyproject.toml).
Moreover the packages such as `PyGObject` and `GExiv2` requires additional system packages that has to be installed using your OS package manager. Please check [requirements.install.apt](requirements.install.apt) for that purpose (tuned on Ubuntu 22.04).
## Installation
``` sh
sudo apt-get install <...> # list from requirements.install.apt
pip3 install -U pip setuptools wheel # optional but recommended
pip3 install smartcrop
```
or directly from GitHub:
``` sh
sudo apt-get install <...> # list from requirements.install.apt
pip3 install -U pip setuptools wheel # optional but recommended
pip install -e git+git://github.com/hhatto/smartcrop.py.git@master#egg=smartcrop
```
## Usage
Use the basic command-line tool:
``` sh
$ smartcroppy --help
usage: smartcroppy [-h] [--debug-file DEBUG_FILE] [--width WIDTH] [--height HEIGHT] INPUT_FILE OUTPUT_FILE
positional arguments:
INPUT_FILE Input image file
OUTPUT_FILE Output image file
options:
-h, --help show this help message and exit
--debug-file DEBUG_FILE
Debugging image file
--width WIDTH Crop width
--height HEIGHT Crop height
```
Processing an image:
``` sh
smartcroppy --width 300 --height 300 tests/images/business-work-1.jpg output.jpg --debug-file debug.jpg
```
Or use the module it in your code (this is a really basic example, see [examples/](examples/) and [smartcrop/cli.py](smartcrop/cli.py) for inspiration):
``` python
import json
import sys
import smartcrop
from PIL import Image
image = Image.open(sys.argv[1])
cropper = smartcrop.SmartCrop()
result = cropper.crop(image, 100, 100)
print(json.dumps(result, indent=2))
```
## Testing
Install dependencies for testing, then call `pytest`:
``` sh
pip3 install smartcrop[test]
pytest
```
## License
MIT
Raw data
{
"_id": null,
"home_page": "",
"name": "smartcrop",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": "",
"keywords": "image,crop,PIL,Pillow",
"author": "",
"author_email": "David Fischer <david@fisch3r.net>, Hideo Hattori <hhatto.jp@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/69/06/000968331f19c847b3edcc3e258b54a552d2a00323aada506354788fb77b/smartcrop-0.4.0.tar.gz",
"platform": null,
"description": "[![image](https://travis-ci.com/smartcrop/smartcrop.py.svg?branch=master)](https://travis-ci.com/smartcrop/smartcrop.py)\n\n# smartcrop.py\n\nsmartcrop implementation in Python.\n\nsmartcrop finds good crops for arbitrary images and crop sizes, based on\nJonas Wagner\\'s [smartcrop.js](https://github.com/jwagner/smartcrop.js).\n\n![image](https://i.gyazo.com/c602d20e025e58f5b15180cd9a262814.jpg){width=\"50.0%\"}\n\n![image](https://i.gyazo.com/5fbc9026202f54b13938de621562ed3d.jpg){width=\"25.0%\"}\n\n![image](https://i.gyazo.com/88ee22ca9e1dd7e9eba7ea96db084e5e.jpg){width=\"50.0%\"}\n\n## Requirements\n\nPython requirements are defined in [pyproject.toml](pyproject.toml).\n\nMoreover the packages such as `PyGObject` and `GExiv2` requires additional system packages that has to be installed using your OS package manager. Please check [requirements.install.apt](requirements.install.apt) for that purpose (tuned on Ubuntu 22.04).\n\n## Installation\n\n``` sh\nsudo apt-get install <...> # list from requirements.install.apt\npip3 install -U pip setuptools wheel # optional but recommended\npip3 install smartcrop\n```\n\nor directly from GitHub:\n\n``` sh\nsudo apt-get install <...> # list from requirements.install.apt\npip3 install -U pip setuptools wheel # optional but recommended\npip install -e git+git://github.com/hhatto/smartcrop.py.git@master#egg=smartcrop\n```\n\n## Usage\n\nUse the basic command-line tool:\n\n``` sh\n$ smartcroppy --help\nusage: smartcroppy [-h] [--debug-file DEBUG_FILE] [--width WIDTH] [--height HEIGHT] INPUT_FILE OUTPUT_FILE\n\npositional arguments:\n INPUT_FILE Input image file\n OUTPUT_FILE Output image file\n\noptions:\n -h, --help show this help message and exit\n --debug-file DEBUG_FILE\n Debugging image file\n --width WIDTH Crop width\n --height HEIGHT Crop height\n```\n\nProcessing an image:\n\n``` sh\nsmartcroppy --width 300 --height 300 tests/images/business-work-1.jpg output.jpg --debug-file debug.jpg\n```\n\nOr use the module it in your code (this is a really basic example, see [examples/](examples/) and [smartcrop/cli.py](smartcrop/cli.py) for inspiration):\n\n``` python\nimport json\nimport sys\n\nimport smartcrop\nfrom PIL import Image\n\nimage = Image.open(sys.argv[1])\ncropper = smartcrop.SmartCrop()\nresult = cropper.crop(image, 100, 100)\nprint(json.dumps(result, indent=2))\n```\n\n## Testing\n\nInstall dependencies for testing, then call `pytest`:\n``` sh\npip3 install smartcrop[test]\npytest\n```\n\n## License\n\nMIT\n",
"bugtrack_url": null,
"license": "",
"summary": "smartcrop implementation in Python",
"version": "0.4.0",
"project_urls": {
"documentation": "https://github.com/smartcrop/smartcrop.py",
"homepage": "https://github.com/smartcrop/smartcrop.py",
"repository": "https://github.com/smartcrop/smartcrop.py"
},
"split_keywords": [
"image",
"crop",
"pil",
"pillow"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "30e6c9afa0eb5bba7e59420cc604a53c9d7e8e226cced88a679da46b31776872",
"md5": "06d4a61b8fc3fa01482137640c197b45",
"sha256": "f000d3176ace8fd90f6a6d602dcec2f6b8ba7a9cc00b272045dd1656ca049ab5"
},
"downloads": -1,
"filename": "smartcrop-0.4.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "06d4a61b8fc3fa01482137640c197b45",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 8580,
"upload_time": "2023-07-05T11:30:55",
"upload_time_iso_8601": "2023-07-05T11:30:55.409605Z",
"url": "https://files.pythonhosted.org/packages/30/e6/c9afa0eb5bba7e59420cc604a53c9d7e8e226cced88a679da46b31776872/smartcrop-0.4.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "6906000968331f19c847b3edcc3e258b54a552d2a00323aada506354788fb77b",
"md5": "5486abb587138a8b6dc8ea06991ecaeb",
"sha256": "7e472f989e2fafe28d96859dd5a0d5b91b8c7c02230ad96b5ba42739d738b199"
},
"downloads": -1,
"filename": "smartcrop-0.4.0.tar.gz",
"has_sig": false,
"md5_digest": "5486abb587138a8b6dc8ea06991ecaeb",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 6633023,
"upload_time": "2023-07-05T11:30:59",
"upload_time_iso_8601": "2023-07-05T11:30:59.065288Z",
"url": "https://files.pythonhosted.org/packages/69/06/000968331f19c847b3edcc3e258b54a552d2a00323aada506354788fb77b/smartcrop-0.4.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-07-05 11:30:59",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "smartcrop",
"github_project": "smartcrop.py",
"travis_ci": true,
"coveralls": false,
"github_actions": false,
"lcname": "smartcrop"
}