Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
102 lines (71 sloc) 2.71 KB

Image Resizing Server

This server provides a service to resize and crop images with a simple API. It's able to hold heavy loads and is easy to use.

It was written in Python, using Tornado web framework, Uwsgi to distribute the application on the network and Nginx front-end.

I want to specially thanks Stéphane Bunel (, he was the initiator of this project, and advised me on how to re-develop this project for open-sourcing.

It's my first open-source project, feel free to contribute.


need sudo :

apt-get install python-pip python-imaging nginx build-essential python-dev libxml2-dev && pip install uwsgi tornado
cd /tmp && git clone && cd ./ImageResizingServer
python install

Attention if you haven't installed nginx you have to remove default conf in sites-enabled (rm /etc/nginx/sites-enabled/default)


You have to define your image clusters. It a simple dict in server.conf

default :

clusterInfos = {
signatureSecret = ""
timeoutGetCluster = 1
defaultQuality = 90
minHeight = 1
maxHeight = 2048
minWidth = 1
maxWidth = 2048

Example :

clusterInfos = {
    'cluster1': '',
    'cluster2': ''
signatureSecret = "MY_SECRET_TOKEN"
timeoutGetCluster = 1
defaultQuality = 100
minHeight = 1
maxHeight = 1024
minWidth = 1
maxWidth = 1024

You have to restart uwsgi after.


Resize an image to 100px width :

Resize an image to 300px height :

Resize an image to 600px width and change is quality to 60% :

Crop an image and resize 200/200px :

Crop an image and resize 200/200px and change quality to 95% :

Securise your application

If you want to securise the application, put a token in configuration directive "signatureSecret".

And after to retrieve the signature you just have to follow this example:

configuration: signatureSecret="YOUR_SECRET_TOKEN"

uri: /cluster1/crop/95/200x200/path/to/image.png

Python :

import hashlib
hashlib.sha512('YOUR_SECRET_TOKEN' + '/cluster1/crop/95/200x200/path/to/image.png').hexdigest()[:4]
result : '61b5'


substr(hash('sha512', 'YOUR_SECRET_TOKEN' . '/cluster1/crop/95/200x200/path/to/image.png'), 0, 4);
result : '61b5'

Final uri : /61b5/cluster1/crop/95/200x200/path/to/image.png