This commit is contained in:
Matthias Vogelgesang
2013-08-02 08:31:28 +02:00
parent e7385b9d0d
commit 4c233b692b
5 changed files with 14 additions and 7 deletions

View File

@@ -1,7 +1,7 @@
# -*- coding:utf-8 -*-
import os
from setuptools import setup, find_packages
from setuptools import setup
requires = ['argh', 'clint', 'jinja2', 'Markdown', 'pilkit']

View File

@@ -41,7 +41,7 @@ from argh import ArghParser, arg
from logging import Formatter
from .gallery import Gallery
from .pkgmeta import *
from .pkgmeta import __version__
from .settings import read_settings
_DEFAULT_CONFIG_FILE = 'sigal.conf.py'

View File

@@ -43,10 +43,12 @@ from .writer import Writer
DESCRIPTION_FILE = "index.md"
class FileExtensionError(Exception):
"""Raised if we made an error when handling file extensions"""
pass
class PathsDb(object):
"""Container for all the information on the directory structure.
@@ -75,7 +77,7 @@ class PathsDb(object):
subdir = [os.path.normpath(os.path.join(path, sub))
for sub in self.db[path].get('subdir', [])]
if subdir:
return subdir + reduce(lambda x, y: x+y,
return subdir + reduce(lambda x, y: x + y,
map(self.get_subdirs, subdir))
else:
return []
@@ -108,7 +110,7 @@ class PathsDb(object):
path_media = [path for path in self.db['paths_list']
if self.db[path]['medias'] and path != '.']
path_nomedia = [path for path in self.db['paths_list']
if not self.db[path]['medias'] and path !='.']
if not self.db[path]['medias'] and path != '.']
# dir with images: check the thumbnail, and find it if necessary
for path in path_media:
@@ -190,8 +192,9 @@ class Gallery(object):
# loop on directories in reversed order, to process subdirectories
# before their parent
for path in reversed(self.db['paths_list']):
media_files = [os.path.normpath(join(self.settings['source'], path, f))
for f in self.db[path]['medias']]
source = self.settings['source']
media_files = [os.path.normpath(join(source, path, f))
for f in self.db[path]['medias']]
# output dir for the current path
outpath = os.path.normpath(join(self.settings['destination'],
@@ -293,6 +296,7 @@ def process_image(filepath, outpath, settings):
settings['thumb_size'], None, fit=settings['thumb_fit'],
options=options)
def process_video(filepath, outpath, settings):
"""Process one image: resize, create thumbnail."""

View File

@@ -38,7 +38,8 @@ _DEFAULT_CONFIG = {
'keep_orig': False,
'orig_dir': 'original',
'jpg_options': {'quality': 85, 'optimize': True, 'progressive': True},
'webm_options': {'crf': '10', 'bitrate': '1.6M', 'qmin': '4', 'qmax': '63'},
'webm_options': {'crf': '10', 'bitrate': '1.6M',
'qmin': '4', 'qmax': '63'},
'copyright': '',
'img_ext_list': ['.jpg', '.jpeg', '.JPG', '.JPEG', '.png'],
'vid_ext_list': ['.MOV', '.mov', '.avi', '.mp4', '.webm', '.ogv'],

View File

@@ -27,6 +27,7 @@ import re
import shutil
import sigal.image
def vid_size(source):
"""Returns the dimensions of the video"""
pattern = re.compile(r'Stream.*Video.* ([0-9]+)x([0-9]+)')
@@ -84,6 +85,7 @@ def generate_video(source, outname, size, options={}):
resize_opt + [outname],
stderr=devnull)
def generate_thumbnail(source, outname, box, format, fit=True, options=None):
"Create a thumbnail image"
# 1) dump an image of the video