Skip to main content

smartcrop implementation in Python

Project description

smartcrop implementation in Python.

smartcrop finds good crops for arbitrary images and crop sizes, based on Jonas Wagner’s smartcrop.js.


  • numpy

  • PIL or Pillow


pip3 install smartcrop

or directly from GitHub:

pip install -e git+git://


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 --debug-file debug.jpg

Or use the module it in your code (this is a really basic example):

import json
import sys

import smartcrop
from PIL import Image

image =[1])

sc = smartcrop.SmartCrop()
result = sc.crop(image, 100, 100)
print(json.dumps(result, indent=2))



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.3.tar.gz (5.8 kB view hashes)

Uploaded source

Built Distribution

smartcrop-0.3.3-py3-none-any.whl (7.2 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page