# HG changeset patch # User Tero Marttila # Date 1244986480 -10800 # Node ID ecceaf23c9697b0df00ecfa66d038ba2740852fd # Parent a5b30b423f79dddb3345accda430e770750608f3 make loading exif metadata optional diff -r a5b30b423f79 -r ecceaf23c969 degal/config.py --- a/degal/config.py Sun Jun 14 16:27:03 2009 +0300 +++ b/degal/config.py Sun Jun 14 16:34:40 2009 +0300 @@ -38,6 +38,10 @@ # number of images displayed per folder page images_per_page = 50 + # load Exif data for images + # this may be slow + exif_enabled = False + # exif tags used in output # Copyright (C) 2008, Santtu Pajukanta # XXX: import from dexif? diff -r a5b30b423f79 -r ecceaf23c969 degal/image.py --- a/degal/image.py Sun Jun 14 16:27:03 2009 +0300 +++ b/degal/image.py Sun Jun 14 16:34:40 2009 +0300 @@ -74,20 +74,28 @@ # load stuff stat = self.stat() - exif = self.exif # XXX: avoid having to open the image? size = self.pil_image.size # build - return dict({ + metadata = dict({ "File name": self.name, "Resolution": "%dx%d" % size, "File size": format.filesize(stat.st_size), "Last modified": format.filetime(stat.st_mtime), - }, **dict( - (name, exif[tag]) for tag, name in self.config.exif_tags if exif and tag in exif - )) + }) + + # optionally load Exif metadata + if self.config.exif_enabled : + exif = self.exif + + # Get the wanted tags + metadata.update(dict( + (name, exif[tag]) for tag, name in self.config.exif_tags if exif and tag in exif + )) + + return metadata def stale (self) : """ diff -r a5b30b423f79 -r ecceaf23c969 degal/main.py --- a/degal/main.py Sun Jun 14 16:27:03 2009 +0300 +++ b/degal/main.py Sun Jun 14 16:34:40 2009 +0300 @@ -26,6 +26,9 @@ parser.add_option("--force-html", dest='force_html', action="store_true", default=False, help="Force-update all .html files") + + parser.add_option("--with-exif", dest='exif_enabled', action="store_true", default=None, + help="Include Exif metadata in updated .html files") parser.add_option('-d', "--debug", dest='debug', action="store_true", default=False, help="Show debug output") @@ -57,6 +60,9 @@ if options.force_html : config.force_html = True + if options.exif_enabled is not None : + config.exif_enabled = options.exif_enabled + if options.debug : config.log_level = config_module.logging.DEBUG