sorl-thumbnail 13.4.0 adds a libvips engine, reads each source image once per request, and fixes rounded corners, borders and blur on transparent images. Each change is explained in full in the changelog.
Highlights
- A new libvips engine. Set
THUMBNAIL_ENGINE = "sorl.thumbnail.engines.vips_engine.Engine"and install it withpip install sorl-thumbnail[vips]. It supports every thumbnail option and keeps ICC profiles and animated GIFs. Use the convert engine for PDF and SVG sources. #833 - Each source is read once per request. Several sizes of one image, or
is_portraitbefore the tag, no longer read the original again each time. On S3 every read was a full download. This works with every engine. #471 - A project homepage with example galleries for each engine: https://mariocesar.github.io/sorl-thumbnail/
Fixes
- Rounded corners work with JPEG in the PIL engine. Before, they crashed with
OSError: cannot write mode RGBA as JPEG. The corners are filled with white, or with the padding color. #849 remove_bordercuts the border exactly, and now trims the empty margins of transparent images, like a PNG logo. PIL and vips engines. #845blurno longer leaves a dark outline around transparent images in the PIL engine.orientation=Falseapplies only to the thumbnail it is given to. Before, it turned off EXIF orientation for later thumbnails until the server restarted. All engines. #843- sorl-thumbnail's
ImageFieldrejects a truncated upload with "Upload a valid image" in the PIL engine, instead of failing later on the thumbnail. #427 - Cached thumbnails keep the
OPTIONSof theirSTORAGESalias whenBACKENDis written the way Django's docs write it. All engines. #834
Removed
- The DynamoDB key-value store. It was built on boto 2, which can't be imported on any supported Python. #838
- The vipsthumbnail engine and its
THUMBNAIL_VIPSTHUMBNAILandTHUMBNAIL_VIPSHEADERsettings. It had failed on every thumbnail since 12.6.3. #833 - The
THUMBNAIL_LAZY_FILL_EMPTYsetting. Nothing read it.
Docs
- New pages: a quickstart, an Amazon S3 guide, troubleshooting, and choosing a thumbnail library. Every option, filter and setting is documented, and the examples run as written.
Before you upgrade
- ASGI on Django 5.2 or 6.0: add
sorl.thumbnail.middleware.SourceCacheMiddlewaretoMIDDLEWARE. WSGI and Django 6.1 need nothing. - Management commands and jobs: wrap the work in
with source_cache():, imported fromsorl.thumbnail. - If a
STORAGESalias setsOPTIONS, likebase_urlorlocation: runpython manage.py thumbnail clearonce. It empties the key-value store without deleting any file. - If you use
remove_border,bluron transparent images, ororientation=False: runpython manage.py thumbnail clear_delete_all, so those thumbnails are made again. It also does what step 3 does. - If
THUMBNAIL_KVSTOREnames the DynamoDB store: remove the setting and pointTHUMBNAIL_CACHEat any Django cache alias. - If
THUMBNAIL_ENGINEnames the vipsthumbnail engine: switch tosorl.thumbnail.engines.vips_engine.Engine.
Links
- Documentation: https://sorl-thumbnail.readthedocs.io/
- Quickstart: https://sorl-thumbnail.readthedocs.io/en/latest/quickstart.html
- Troubleshooting: https://sorl-thumbnail.readthedocs.io/en/latest/troubleshooting.html
- Examples: https://mariocesar.github.io/sorl-thumbnail/
- Changelog: https://github.com/mariocesar/sorl-thumbnail/blob/main/CHANGES.rst#1340
- PyPI: https://pypi.org/project/sorl-thumbnail/13.4.0/
- Report a bug: https://github.com/mariocesar/sorl-thumbnail/issues/new/choose
Full Changelog: 13.3.0...13.4.0