pypi sorl-thumbnail 13.4.0

5 hours ago

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 with pip 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_portrait before 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_border cuts the border exactly, and now trims the empty margins of transparent images, like a PNG logo. PIL and vips engines. #845
  • blur no longer leaves a dark outline around transparent images in the PIL engine.
  • orientation=False applies 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 ImageField rejects a truncated upload with "Upload a valid image" in the PIL engine, instead of failing later on the thumbnail. #427
  • Cached thumbnails keep the OPTIONS of their STORAGES alias when BACKEND is 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_VIPSTHUMBNAIL and THUMBNAIL_VIPSHEADER settings. It had failed on every thumbnail since 12.6.3. #833
  • The THUMBNAIL_LAZY_FILL_EMPTY setting. 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

  1. ASGI on Django 5.2 or 6.0: add sorl.thumbnail.middleware.SourceCacheMiddleware to MIDDLEWARE. WSGI and Django 6.1 need nothing.
  2. Management commands and jobs: wrap the work in with source_cache():, imported from sorl.thumbnail.
  3. If a STORAGES alias sets OPTIONS, like base_url or location: run python manage.py thumbnail clear once. It empties the key-value store without deleting any file.
  4. If you use remove_border, blur on transparent images, or orientation=False: run python manage.py thumbnail clear_delete_all, so those thumbnails are made again. It also does what step 3 does.
  5. If THUMBNAIL_KVSTORE names the DynamoDB store: remove the setting and point THUMBNAIL_CACHE at any Django cache alias.
  6. If THUMBNAIL_ENGINE names the vipsthumbnail engine: switch to sorl.thumbnail.engines.vips_engine.Engine.

Links

Full Changelog: 13.3.0...13.4.0

Don't miss a new sorl-thumbnail release

NewReleases is sending notifications on new releases.