From 42d3602e1eaa293b3f3e2b99db4adee93213f682 Mon Sep 17 00:00:00 2001 From: Simon Date: Thu, 5 May 2011 23:32:01 +0200 Subject: [PATCH] try to find a landscape image for the representative --- sigal/theme.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/sigal/theme.py b/sigal/theme.py index 2276750..b0cf21b 100644 --- a/sigal/theme.py +++ b/sigal/theme.py @@ -4,6 +4,7 @@ """render theme for sigal""" import os +import Image from distutils.dir_util import copy_tree from jinja2 import Environment, PackageLoader import sigal.image @@ -13,7 +14,7 @@ INDEX_PAGE = "index.html" IGNORED_DIR = ['css', 'js', 'img'] class Theme(): - """ Generate html """ + """ Generate html pages for each directory of images """ def __init__(self, params, path, theme=DEFAULT_THEME, tpl=INDEX_PAGE): self.path = path @@ -59,6 +60,14 @@ class Theme(): files = [f for f in os.listdir(path) if os.path.isfile(os.path.join(path, f)) \ and os.path.splitext(f)[1] in self.fileExtList] + + for f in files: + # find and return the first landscape image + im = Image.open(os.path.join(path, f)) + if im.size[0] > im.size[1]: + return f + + # else simply return the 1st image return files[0] def render(self):