sorl-thumbnail

sorl-thumbnail

Thumbnails for Django. Resize, crop and convert images from your templates. sorl-thumbnail makes each thumbnail once, saves it through your Django storage, and gives you its URL.

Install

pip install "sorl-thumbnail[pil]"

Add "sorl.thumbnail" to INSTALLED_APPS. The quickstart gets you to a first thumbnail, and the installation guide covers the settings, the key-value store and what each image engine needs.

Example

Mona Lisa, original
OriginalJPEG · 1071×1600 · 390.4 KB
Mona Lisa cropped to a square around the center
ThumbnailJPEG · 300×300 · 29.3 KB
{% load thumbnail %}
{% thumbnail "images/mona-lisa.jpg" "300x300" crop="center" as im %}
  <img src="{{ im.url }}" loading="lazy"
       width="{{ im.width }}" height="{{ im.height }}"
       alt="Mona Lisa cropped to a square around the center">
{% endthumbnail %}

More in the examples, one page per image engine.

Features

Engines

Set the engine with THUMBNAIL_ENGINE. Pillow is the default. Each name links to its examples.

Engine and what it needsDoesn't support
Pillow
pip install pillow
—
libvips
pip install sorl-thumbnail[vips]
—
ImageMagick
the ImageMagick commands
smart crop, rounded corners, blur, border removal
GraphicsMagick
the gm command from GraphicsMagick
smart crop, rounded corners, blur, border removal, AVIF output
Wand
pip install wand, and ImageMagick
smart crop, rounded corners, blur, border removal, padding
pgmagick
pip install pgmagick
smart crop, rounded corners, blur, border removal, padding

Help and contributing

History

Mikko Hellsing wrote sorl-thumbnail in 2010. Mario-César started contributing in 2013 and maintains it today. From 2017 to 2026 it was part of Jazzband, and it now lives at github.com/mariocesar/sorl-thumbnail. Every release is listed in the changelog.