Croppola logo

Getting Started Technical Support


Flexible Cropping Fixed-ratio Cropping Fixed-shape Cropping Command Line Thumbnail Creation Python

Croppola Documentation – Examples

Python can be accessed using the requests library for Python. The two following scripts may serve as starting point to integrate croppola into your Python project.

Cropping a single picture

The following Python script uploads a picture (tea.jpg) to for cropping, and stores the resulting crop:

import os, requests

# Open the original picture
data = open('tea.jpg', 'rb')

# Make the request
url = ''
res =, data=data)

# Save the cropped picture
if res.status_code == 200:
    f = open('tea-cropped.jpg', 'wb')
    print('Error ' + res.status_code + '!')

To change the aspect ratio, or other parameters, simply modify the URL.

Batch cropping all pictures within a folder

Similarly, the following script processes all pictures within the original folder, and stores the crops in the cropped folder:

import os, requests

# Prepare the folders
originalFolder = 'original'
croppedFolder = 'cropped'

if not os.path.exists(croppedFolder):

# This is the URL
url = ''

# Process all pictures
for pictureFile in os.listdir(originalFolder):
    data = open(originalFolder + '/' + pictureFile, 'rb')
    res =, data=data, headers={'User-Agent' : 'py'})
    if res.status_code == 200:
        f = open(croppedFolder + '/' + pictureFile, 'wb')
        print('Error ' + res.status_code)

Note that is available free of charge for a volume of up to 100 photos per day, 500 photos per months, or 2400 photos per year. Above that, please request an API key.