Skip to main content

sorl-thumbnail on PyPI Supported Python versions Supported Django versions Documentation for latest version gh-actions Coverage pre-commit.ci status

Thumbnails for Django.

Features at a glance

  • Support for Django 5.2, 6.0, and 6.1 following the Django supported versions policy

  • Storage support

  • Pluggable Engine support for Pillow, ImageMagick, PIL, Wand, pgmagick, and vipsthumbnail

  • Pluggable Key Value Store support (cached db, redis, and dynamodb by AWS)

  • Pluggable Backend support

  • Admin integration with possibility to delete

  • Dummy generation (placeholders)

  • Flexible, simple syntax, generates no html

  • 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)

Developers

By contributing you agree to abide by the Code of Conduct. To report a security issue, follow the security policy instead of opening a public issue.

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 GitHub Discussions.

Tests

The tests should run with tox. 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. The easiest way to run tests is using Docker - see the contributing documentation for detailed instructions on running tests locally with Docker.

User Support

If you need help using sorl-thumbnail ask in the Q&A category of GitHub Discussions.

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.

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',

    'sorl.thumbnail',
]

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

You can use sorl.thumbnail.ImageField in your models:

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)
delete(my_file)

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

Using in combination with other thumbnailers

Alternatively, you load the templatetags by {% load sorl_thumbnail %} instead of traditional {% load thumbnail %}. It’s especially useful in projects that do make use of multiple thumbnailer libraries that use the same name (thumbnail) for the templatetag module:

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

Frequently asked questions

Is so slow in Amazon S3!

Possible 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:

THUMBNAIL_FORCE_OVERWRITE = True

So it will avoid to overly query the S3 API.

Metadata

Release files for sorl-thumbnail 13.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sorl-thumbnail 13.2.0
File Size Uploaded
sorl_thumbnail-13.2.0.tar.gz 676.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for sorl-thumbnail 13.2.0
File Interpreter ABI Platform
sorl_thumbnail-13.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 719.3 kB

Release files / sorl_thumbnail-13.2.0.tar.gz

Download URL sorl_thumbnail-13.2.0.tar.gz
Size 676.3 kB
Tags Source
SHA-256 checksum
How to use checksums
f3ae9a997485b316d4a44c2d9bf16eb0ab4aa245c6be743e5d34a728eaab59dd
BLAKE2b-256 checksum
How to use checksums
7ac99dd02779d9c7fd4a873a0a8a89f1840d748491f0cfa89b111569e96d13aa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 13, 2026.

Transparency log

Release files / sorl_thumbnail-13.2.0-py3-none-any.whl

Download URL sorl_thumbnail-13.2.0-py3-none-any.whl
Size 43.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3bf689e9c5ab3b7115bf22b02bca3e65e7d06c4eb76797afd60f9417aa76b7b0
BLAKE2b-256 checksum
How to use checksums
cf97453310d684adb6fb7fb8b2f69031543ecd75162a66faa0d61b2f6edd58f4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 13, 2026.

Transparency log
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page