Croppola logo

Getting Started Technical Support

Examples

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

Croppola Documentation – Examples

Thumbnail Creation

Croppola.com exposes a simple web interface, that can be accessed from the command line using tools like cURL. With a few lines of code, a large number of images can be processed automatically, e.g. for creating thumbnails.

Note that the croppola service 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.

Manually generate a smart thumbnail

Through the scaledWidth or scaledMaximumWidth parameters, croppola can rescale the final crop to a given size. The following will create a square thumbnail of size 200x200 pixels with the most interesting part of yourimage.jpg:

curl -X POST --data-binary @yourimage.jpg \
	'http://croppola.com/croppola/image.jpg?aspectRatio=1.0&minimumHeight=80%&scaledMaximumWidth=200&algorithm=croppola' \
	> yourimage-thumbnail.jpg

Batch thumbnail creation

If you have more than just a few images, you may want to do this process automatically for all images. The following Perl script is a good starting point:

#! /usr/bin/perl
use strict;
use File::Basename;

mkdir 'thumbnails';
while (my $file = shift) {
	my $basename = basename($file);
	system("curl -X POST --data-binary \@$file 'http://croppola.com/croppola/image.jpg?aspectRatio=1.0&minimumHeight=80%&scaledMaximumWidth=200&algorithm=croppola' > thumbnails/$basename");
}

The script takes each file from the argument list, and processes it through croppola. The resulting images are written to the thumbnails folder. Copy the above text into a file (e.g. create-thumbnails), modify the desired aspect ratio (here 1.0) and thumbnail size (here 200), and use it as follows:

chmod 755 create-thumbnails
./create-thumbnails path/to/pictures/*.jpg

If Perl isn't your style, you can of course write a similar script in another language (e.g. bash, Python).