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.

Files for smartcrop, version 0.3.3
Filename, size File type Python version Upload date Hashes
Filename, size smartcrop-0.3.3-py3-none-any.whl (7.2 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size smartcrop-0.3.3.tar.gz (5.8 kB) File type Source Python version None Upload date Hashes View

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 Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page