pypi sorl-thumbnail 13.3.0

2 hours ago

What's Changed

  • The convert and vipsthumbnail engines run their tools through subprocess.run. This fixes a deadlock when a tool wrote more than the pipe buffer to stderr, and closes the pipes that is_valid_image and the size probes left open. A call that runs longer than the new THUMBNAIL_COMMAND_TIMEOUT setting, 60 seconds by default, is killed and raises EngineError. Set it higher for large sources, or to None for the previous unbounded behaviour

  • The vipsthumbnail engine no longer fails on any stderr output, which made every thumbnail fail on a libvips that prints a warning on startup. It checks the exit code like the convert engine does, and raises EngineError instead of a bare Exception or AttributeError when vipsthumbnail or vipsheader fail

  • crop='smart' now returns the requested size. It could hang forever, raise ValueError, or return a thumbnail that was too narrow, like 44×200 for 200x200 (#829)

  • Documented crop='smart'. It only works with the PIL engine, and the other engines now say so in the error instead of raising an empty NotImplementedError

  • The convert engine raises an error when convert writes a different format than the one requested. Without an AVIF encoder, ImageMagick printed a warning, exited with 0 and wrote a JPEG, which was saved under an .avif name (#837). Browsers displayed those files, so sites that ask for AVIF on such a machine will now see the thumbnail tag fail instead. Install libheif-plugin-aomenc or ask for WEBP. Thumbnails created before the upgrade keep working

  • The PIL engine writes a greyscale source with an alpha channel (mode LA) as JPEG instead of raising OSError: cannot write mode RGBA as JPEG (#474)

  • The PIL and wand engines now honour THUMBNAIL_FLATTEN, which is now documented along with the flatten option. A transparent source written as JPEG shows the color stored under its transparent pixels, usually black. With the setting on it is composited onto a white background, or the padding color when the thumbnail is padded (#474). The convert engine already flattened, and does so for every format, so its PNG, GIF and WEBP thumbnails lose their transparency too. flatten=False now turns it off for one thumbnail, before only the string "off" did. The setting is not part of the thumbnail name, so thumbnails created before the upgrade keep their black background until you delete them, for example with manage.py thumbnail clear_delete_all

  • The cached DB key-value store writes every entry with a single upsert instead of a lookup followed by an insert or update, so creating a thumbnail runs six statements instead of nine. Oracle has no upsert in Django and keeps the two-step write (#451)

  • Documented THUMBNAIL_FORCE_OVERWRITE and stopped recommending it for Amazon S3. On a key-value store miss it regenerates the thumbnail from the full-size source where the default makes one HEAD request, so with boto3 it makes S3 slower, not faster (#351)

  • The convert engine now reports the padded size when padding=True, so im.width and im.height match the file it wrote instead of the size before padding (#835)

  • The PIL engine keeps animated GIFs animated when the thumbnail format is GIF. Every frame is thumbnailed, keeping its duration and the loop count. Other formats still take the first frame (#687)

  • UrlStorage no longer escapes + and / in the query string of remote image URLs, which broke signed URLs. Only applies with THUMBNAIL_REMOVE_URL_ARGS = False, the default strips the query first

  • The default branch is now main instead of master. GitHub redirects links to master to main. To update an existing clone or fork:

    git branch -m master main
    git fetch origin
    git branch -u origin/main main
    git remote set-head origin -a
    

New Contributors

Full Changelog: 13.2.0...13.3.0

Don't miss a new sorl-thumbnail release

NewReleases is sending notifications on new releases.