* fix thumbnailing
* make thumbnailing programs configurable
This commit is contained in:
parent
8665b98452
commit
cc957f3de5
@ -127,3 +127,7 @@ ASSETS_ROOT = os.path.join(BASE_DIR, 'assets')
|
|||||||
|
|
||||||
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
|
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
|
||||||
MEDIA_URL = '/media/'
|
MEDIA_URL = '/media/'
|
||||||
|
|
||||||
|
# for thumbnailing
|
||||||
|
CONVERT_PATH = '/usr/bin/convert'
|
||||||
|
FFMPEG_PATH = '/usr/bin/ffmpeg'
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
|
from django.conf import settings
|
||||||
import subprocess
|
import subprocess
|
||||||
import os
|
import os
|
||||||
img_ext = ['png', 'jpg', 'jpeg', 'gif', 'webp', 'ico']
|
img_ext = ['png', 'jpg', 'jpeg', 'gif', 'webp', 'ico', 'pdf', 'ps']
|
||||||
vid_ext = ['mp4', 'webm', 'm4v', 'ogv', 'avi']
|
vid_ext = ['mp4', 'webm', 'm4v', 'ogv', 'avi', 'txt']
|
||||||
txt_ext = ['txt', 'pdf', 'ps']
|
|
||||||
|
|
||||||
def generate(fname, tname, placeholder):
|
def generate(fname, tname, placeholder):
|
||||||
"""
|
"""
|
||||||
@ -11,9 +11,9 @@ def generate(fname, tname, placeholder):
|
|||||||
ext = fname.split('.')[-1]
|
ext = fname.split('.')[-1]
|
||||||
cmd = None
|
cmd = None
|
||||||
if ext in img_ext:
|
if ext in img_ext:
|
||||||
cmd = ['/usr/bin/convert', '-thumbnail', '200', fname, tname]
|
cmd = [settings.CONVERT_PATH, '-thumbnail', '200', fname, tname]
|
||||||
elif ext in vid_ext or ext in txt_ext:
|
elif ext in vid_ext:
|
||||||
cmd = ['/usr/bin/ffmpeg', '-i', fname, '-vf', 'scale=300:200', '-vframes', '1', tname]
|
cmd = [settings.FFMPEG_PATH, '-i', fname, '-vf', 'scale=300:200', '-vframes', '1', tname]
|
||||||
|
|
||||||
if cmd is None:
|
if cmd is None:
|
||||||
os.link(placeholder, tname)
|
os.link(placeholder, tname)
|
||||||
|
Reference in New Issue
Block a user