merged http://pajukanta.fi/temp/degal_exif_r33.tar.bz2 patch from Japsu
authorterom
Sun, 04 May 2008 18:23:03 +0000
changeset 33 4943047bfcb5
parent 32 cc2d9db311c0
child 34 1fee720888c9
merged http://pajukanta.fi/temp/degal_exif_r33.tar.bz2 patch from Japsu
lib/image.py
templates/image.html
--- 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,
--- 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 @@
     </div>
     <div id="info">
 % if img_size and file_size and timestamp :    
-      <p>${filename}</p>
-      <p>${h.format_imgsize(img_size)}</p>
-      <p>${h.format_filesize(file_size)}</p>
-      <p>${h.format_timestamp(timestamp)}</p>
+      <p>File name: ${filename}</p>
+      <p>Dimensions: ${h.format_imgsize(img_size)}</p>
+      <p>File size: ${h.format_filesize(file_size)}</p>
+      <p>Last modified: ${h.format_timestamp(timestamp)}</p>
+% for key, value in exif_data :
+      <p>${key}: ${value}</p>
+% endfor
+
 % endif    
       <p>ShortURL: <a href="${shorturl}" rel="nofollow">${shorturl_code}</a></p>
 % if series_url :