# HG changeset patch # User terom # Date 1209925383 0 # Node ID 4943047bfcb510140dd3fda140149d100d135c4b # Parent cc2d9db311c07dbceef04c596a39c01b868af73f merged http://pajukanta.fi/temp/degal_exif_r33.tar.bz2 patch from Japsu diff -r cc2d9db311c0 -r 4943047bfcb5 lib/image.py --- a/lib/image.py Tue Mar 18 00:04:02 2008 +0000 +++ b/lib/image.py Sun May 04 18:23:03 2008 +0000 @@ -22,6 +22,8 @@ import PIL.Image +import dexif + import settings, utils, log from template import image as image_tpl @@ -68,6 +70,9 @@ # the ShortURL code for this image self.shorturl_code = None + # EXIF data + self.exif_data = {} + # what to use in the rendered templates, intended to be overridden by subclasses self.series_act = "add" self.series_verb = "Add to" @@ -124,6 +129,14 @@ if utils.mtime(self.html_path) < self.timestamp : log.info("render %s.html", self.name) + # parse the exif data from the file + try : + self.exif_data = dexif.parse_exif(self.path) + except dexif.ExifError, message: + log.warning("Reading EXIF data for %s failed: %s" % (self.filename, message)) + self.exif_data = {} + + image_tpl.render_to(self.html_path, stylesheet_url = self.dir.inRoot('style.css'), title = self.title, @@ -139,6 +152,7 @@ img_size = self.img_size, file_size = self.filesize, timestamp = self.timestamp, + exif_data = self.exif_data, shorturl = self.dir.inRoot('s', self.shorturl_code), shorturl_code = self.shorturl_code, diff -r cc2d9db311c0 -r 4943047bfcb5 templates/image.html --- a/templates/image.html Tue Mar 18 00:04:02 2008 +0000 +++ b/templates/image.html Sun May 04 18:23:03 2008 +0000 @@ -20,10 +20,14 @@
% if img_size and file_size and timestamp : -

${filename}

-

${h.format_imgsize(img_size)}

-

${h.format_filesize(file_size)}

-

${h.format_timestamp(timestamp)}

+

File name: ${filename}

+

Dimensions: ${h.format_imgsize(img_size)}

+

File size: ${h.format_filesize(file_size)}

+

Last modified: ${h.format_timestamp(timestamp)}

+% for key, value in exif_data : +

${key}: ${value}

+% endfor + % endif

ShortURL: ${shorturl_code}

% if series_url :