You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
1.1 KiB
39 lines
1.1 KiB
9 years ago
|
# -*- coding: utf-8 -*-
|
||
|
from __future__ import unicode_literals
|
||
|
# Erik Stein <code@classlibrary.net>, 2016
|
||
|
|
||
|
|
||
|
class UniversalThumbnail(ImageSpec):
|
||
|
"""
|
||
|
Produces thumbnail images from any type of media, using
|
||
|
per-type initial conversion to an image.
|
||
|
"""
|
||
|
slug = 'thumbnail'
|
||
|
not_applicable_types = (UNKNOWN, AUDIO, DOCUMENT)
|
||
|
base_conversion_map = {
|
||
|
IMAGE: [],
|
||
|
MOVIE: [],
|
||
|
}
|
||
|
_processors = [ResizeToFill(100, 50)]
|
||
|
format = 'JPEG'
|
||
|
options = {'quality': 60}
|
||
|
|
||
|
@property
|
||
|
def processors(self):
|
||
|
instance, field_name = get_field_info(self.source)
|
||
|
if instance.media_type in self.not_applicable_types:
|
||
|
raise ConversionNotApplicable
|
||
|
|
||
|
if instance.media_type ==
|
||
|
|
||
|
processors = self.base_conversion_map[instance.media_type]
|
||
|
|
||
|
|
||
|
"""
|
||
|
Dynamic spec, depending on the source's media type
|
||
|
e.g. first convert a movie to an image, depending on a time code
|
||
|
for the movie poster
|
||
|
|
||
|
see http://django-imagekit.readthedocs.org/en/develop/advanced_usage.html#specs-that-change
|
||
|
"""
|