Automatic thumbnail format for Sorl

UPDATE: now built in to sorl-thumbnail


The following sorl.thumbnail backend sets the THUMBNAIL_FORMAT automatically based on the original filename, using the THUMBNAIL_FORMAT setting if the format cannot be automatically inferred.

Usage

Place sorl_backends.py on your path, and add the following to your django settings.

THUMBNAIL_BACKEND = 'sorl_backends.AutoFormatBackend'

# Used if the format cannot be automatically inferred (eg for a .gif image)
THUMBNAIL_FORMAT = 'JPEG'

Download the code at https://gist.github.com/1052476.

Source Code


Loading