--- a/lib/image.py Thu Jan 31 17:58:03 2008 +0000
+++ b/lib/image.py Thu Jan 31 19:13:00 2008 +0000
@@ -22,8 +22,7 @@
import PIL.Image
-import settings, utils
-from log import index, render
+import settings, utils, log
from template import image as image_tpl
class Image (object) :
@@ -104,13 +103,15 @@
for out_path, geom in ((self.thumb_path, settings.THUMB_GEOM), (self.preview_path, settings.PREVIEW_GEOM)) :
# if it doesn't exist, or it's older than the image itself, generate
- if not (os.path.exists(out_path) and os.stat(out_path).st_mtime > self.timestamp) :
- render.info("Create thumbnailed image at %s with geom %s", out_path, geom)
+ if utils.mtime(out_path) < self.timestamp :
+ log.info("render [%sx%s]", geom[0], geom[1], wait=True)
# XXX: is this the most efficient way to do this? It seems slow
out_img = img.copy()
out_img.thumbnail(geom, resample=True)
out_img.save(out_path)
+
+ log.done()
# look for the metadata file
title_path = self.dir.pathFor(self.base_name + '.txt')
@@ -119,31 +120,33 @@
if not self.title :
self.title = self.name
-
- render.info("Rendering image %s", self.path)
+
+ if utils.mtime(self.html_path) < self.timestamp :
+ log.info("render %s.html", self.name)
- image_tpl.render_to(self.html_path,
- stylesheet_url = self.dir.inRoot('style.css'),
- title = self.title,
- breadcrumb = self.breadcrumb(),
-
- prev = self.prev,
- next = self.next,
- img = self,
-
- description = self.descr,
-
- filename = self.name,
- img_size = self.img_size,
- file_size = self.filesize,
- timestamp = self.timestamp,
-
- shorturl = self.dir.inRoot('s', self.shorturl_code),
- shorturl_code = self.shorturl_code,
-
- series_url = self.dir.inRoot('series/%s/%s' % (self.series_act, self.shorturl_code)),
- series_verb = self.series_verb,
- )
+ image_tpl.render_to(self.html_path,
+ stylesheet_url = self.dir.inRoot('style.css'),
+ title = self.title,
+ breadcrumb = self.breadcrumb(),
+
+ prev = self.prev,
+ next = self.next,
+ img = self,
+
+ description = self.descr,
+
+ filename = self.name,
+ img_size = self.img_size,
+ file_size = self.filesize,
+ timestamp = self.timestamp,
+
+ shorturl = self.dir.inRoot('s', self.shorturl_code),
+ shorturl_code = self.shorturl_code,
+
+ series_url = self.dir.inRoot('series/%s/%s' % (self.series_act, self.shorturl_code)),
+ series_verb = self.series_verb,
+ )
def __str__ (self) :
return "Image `%s' in `%s'" % (self.name, self.dir.path)
+