Work in progress: django-imagekit but for all types of media files (movies, PDFs etc.).
+ private media
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.
|
|
|
# -*- 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 == 1:
|
|
|
|
pass
|
|
|
|
|
|
|
|
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
|
|
|
|
"""
|