How to get a professional and automatic aspect ratio crop for your images on your digital picture frame 2

How to get a professional and automatic aspect ratio crop for your images on your digital picture frame

In your digital picture frame, you are likely to have photos that were taken by various people using different cameras. This typically means that your photo files will have many inconsistent aspect ratios. Some may be 4:3 (Four-Thirds cameras), others 3:2 (DSLR), and everything in between is possible with a smartphone.

The digital picture frame only has one format, typically 16:10 or 16:9. The effect of a non-format-adjusted family & friends photo collection can be pillar or letterboxing.

The online service Croppola uses sophisticated image recognition software to find the best composition and crop in a photo automatically. We talked to the Croppola team in Switzerland and will show you a Python script which automates the cropping process for your images.

A well maintained digital picture frame needs some love

A digital picture frame requires only little maintenance, but there is one thing that needs to be done right when you upload to new images: The images need to have the right aspect ratio.

However, manually checking and cropping many hundred images or even more is not only very time consuming and requires the right photo software but it also asks for a bit of a photographer’s eye.

As “making it really simple” is one of the critical success ingredients of a digital picture frame (and needed to get the stamp of approval from other household members), I did a fair amount of research to test-drive several online cropping tools.

Following many hours of researching and testing various online tools, I came across Croppola, a solution that I can highly recommend to anyone.

If you want your images to be intelligently cropped to the exact aspect ratio of your digital picture frame, then Croppola is the way to go.

Francis Ford C(r)oppola

How to get a professional and automatic aspect ratio crop for your images on your digital picture frame 3

Croppola is the brainchild of Radhakrishna Achanta, a former Ph.D. student in the field of Computer Vision at the EPFL University of Lausanne in Switzerland. Out of appreciation for a movie director, the product name was born.

Within the Image and Visual Representation Group (IVRG), directed by Professor Sabine Süsstrunk he developed a clever image recognition algorithm that automatically recognizes faces, colors and other objects in videos.

In 2012 this know-how was applied to photos, and Achanta’s Ph.D. student colleague Thomas Lochmatter created a website to make the Croppola technology available to the public.

I talked with Thomas Lochmatter, an IT consultant for distributed data systems, about Croppola. Since 2012, Thomas has developed and maintained the software and servers of the Croppola project.

It’s a kind of magic

Croppola serves up over 100,000 cropped images through its website every month. The service is accessible either through uploading images on the site or through an API.

Although there are paying high-volume cropping corporate customers, Croppola remains mainly a research project with monetization only being given second thoughts. This is why, luckily, the cropping service is free for users with less than 500 images a month.

Croppola is super fast, and the hit rate of getting the right crop is astonishingly high. Artistic tastes are a personal matter, so there will always be instances where a person may prefer a different crop, but for automating the cropping process for a digital picture frame, Croppola is more than ideal.

It reminded me of the face recognition feature of photo software like Adobe Lightroom or Apple Photos. But Croppola recognizes a lot more than just faces.

Thomas mentioned corporate projects where Croppola was integrated into the value chain of their clients, automating the process of cropping people photos into fixed shape objects and saving the client a lot of work.

Two things that I would wish for future developments: One is that the JPG compression quality, which is currently fixed at 95%, can be specified or set to 100%. The other one is the preservation of EXIF data. Unfortunately, they are removed today after cropping, which is not great if other automation scripts depend on EXIF data. An example would be the filtering of images based on dates or locations. Thankfully, Thomas offered that he would look into these issues.

The Python script that will save you many hours

Croppola offers an API that lets you batch upload images that are subsequently analyzed, cropped, and resized. This means that you can run a Python script in the background, which automatically triggers the upload and cropping of new images.

The automatic folder supervision to trigger the Croppola script will be described in a later post, but the following Python script from Thomas does a great job of looking into a folder for new images, uploading them to Croppola and saving the resized images to a new folder. All that’s left to do is to copy the newly cropped images to your final images folder.

In this example, I have specified the cropping for a 16:10, 1920 x 1200 px picture frame, but you can define the aspect ratio and the final pixel dimensions as you need it.

Paste the following code in a text editor and save it as

#!/usr/bin/env python3
import os, requests, time

# Prepare the folders
originalFolder = 'new-images-inbox'
croppedFolder = 'new-images-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 =, headers={'User-Agent' : 'py'})
    if res.status_code == 200:
        f = open(croppedFolder + '/' + pictureFile, 'wb')
        time.sleep(5)	# let other people crop
        print('Error ' + res.status_code)

Adjust the settings to fit your digital picture frame in this section:

# This is the URL
url = ''

If your aspect ratio is e.g., “16:9” and your monitor resolution is 1920 x 1080, you can easily define it in this line.

There are a lot of individual settings that Croppola allows. You can find further information on their homepage. But for our purpose, this is all you need.

Move the Python file into the “Pictures” folder of your Raspberry Pi.

I assume that you have your SMB file sharing connection set up. If not, read how to set it up in “How to set up your Raspberry Pi for your digital picture frame“.

To test it, add a few images to the “new-images-inbox” folder.

Open up your Terminal, and connect to your Raspberry Pi.

ssh pi@IP-of-your-RaspberryPi

Change to the Pictures directory

cd Pictures

Then enter


Croppola should now convert your files and place the output into the “new-images-cropped” folder.

Check if the images have the right size, as you specified.

You’re done! No more tedious cropping and size conversion, Croppola will automate this process for you.


A big “Thank You” to the team behind Croppola and especially Thomas Lochmatter who provided the Python script and gave me some more background. You guys rock!

Was this article helpful?

Scroll to Top