Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Python HTML Shell
Latest commit e229a64 @mariocesar 12.4 Pre alpha release


travis pypi coveralls

Thumbnails for Django.

Features at a glance

  • Support for Django 1.4, 1.5, 1.6, 1.7 and 1.8
  • Python 3 support (for Django 1.5, 1.6, 1.7, 1.8)
  • Storage support
  • Pluggable Engine support for Pillow, ImageMagick, PIL, Wand and pgmagick
  • Pluggable Key Value Store support (cached db, redis)
  • Pluggable Backend support
  • Admin integration with possibility to delete
  • Dummy generation (placeholders)
  • Flexible, simple syntax, generates no html
  • ImageField for model that deletes thumbnails
  • CSS style cropping options
  • Back smart cropping, and remove borders from the images when cropping
  • Margin calculation for vertical positioning
  • Alternative resolutions versions of a thumbnail

Read more in the documentation (latest version)


Feel free to create a new Pull request if you want to propose a new feature. If you need development support or want to discuss with other developers join us in the channel #sorl-thumnbnail at or Gitter.

For releases updates and more in deep development discussion use our mailing list in Google Groups.


The tests should run with tox and pytest. Running tox will run all tests for all environments. However, it is possible to run a certain environment with tox -e <env>, a list of all environments can be found with tox -l. These tests require the dependencies of the different engines defined in the documentation. It is possible to install these dependencies into a vagrant image with the Vagrantfile in the repo.

User Support

If you need help using sorl-thumbnail browse and posts your questions with the sorl-thumbnail tag.

How to Use

Get the code

Getting the code for the latest stable release use 'pip'.

$ pip install sorl-thumbnail

Install in your project

Then register 'sorl.thumbnail', in the 'INSTALLED_APPS' section of your project's settings.



Templates Usage

All of the examples assume that you first load the thumbnail template tag in your template.:

{% load thumbnail %}

A simple usage.

{% thumbnail item.image "100x100" crop="center" as im %}
    <img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}">
{% endthumbnail %}

See more examples in the section Template examples in the Documentation

Model Usage

Using the ImageField that automatically deletes references to itself in the key value store and its thumbnail references and the thumbnail files when deleted.:

from django.db import models
from sorl.thumbnail import ImageField

class Item(models.Model):
    image = ImageField(upload_to='whatever')

See more examples in the section Model examples in the Documentation

Low level API

You can use the 'get_thumbnail':

from sorl.thumbnail import get_thumbnail
from sorl.thumbnail import delete

im = get_thumbnail(my_file, '100x100', crop='center', quality=99)

See more examples in the section Low level API examples in the Documentation

Frequently asked questions

Is so slow in Amazon S3 !

Posible related to the implementation of your Amazon S3 Backend, see the issue `#351`_ due the storage backend reviews if there is an existing thumbnail when tries to generate the thumbnail that makes an extensive use of the S3 API

A fast workaround if you are not willing to tweak your storage backend is to set the THUMBNAIL_FORCE_OVERWRITE setting to True by default is False, so it will avoid to overly query the S3 API

Something went wrong with that request. Please try again.