Skip to content
Browse files

Remove dependency upon pyexiv2 (can use PIL to read).

  • Loading branch information...
1 parent 98dc93d commit fa461a8231788667e4295f754dad259d0a717880 @mnot committed Jun 26, 2012
Showing with 13 additions and 11 deletions.
  1. +13 −11 photoweb/__init__.py
View
24 photoweb/__init__.py
@@ -57,6 +57,11 @@ class PhotoWebber(object):
# encoding
enc = 'utf-8'
+ _iptc_tags = {
+ (2,5): "ObjectName",
+ (2,120): "Caption",
+ }
+
def __init__(self, options):
self.options = options
self.tpl, self.tpl_md = self.load_tpl()
@@ -239,33 +244,30 @@ def load_pics(self, photo_dir):
'title': md.get('Iptc.ObjectName', ''),
'caption': md.get('Iptc.Caption', ''),
'date': md.get('Exif.DateTimeOriginal', ''),
- 'w': md.get('Exif.PixelXDimension', ''),
- 'h': md.get('Exif.PixelYDimension', ''),
+ 'w': md.get('Exif.ExifImageWidth', ''),
+ 'h': md.get('Exif.ExifImageHeight', ''),
})
return pics
- _iptc_tags = {
- (2,5): "ObjectName",
- (2,120): "Caption",
- }
@staticmethod
def mdget(phile):
- out = {}
try:
im = Image.open(phile)
except IOError, why:
sys.stderr.write("Can't find metadata for %s (%s).\n" %
(phile, why)
)
return None
- exif_info = im._getexif()
+ out = {}
+ exif_info = im._getexif() or {}
for tag, value in exif_info.items():
decoded = ExifTags.TAGS.get(tag, "unknown")
- out["exif." + decoded] = value
+ out["Exif." + decoded] = value
iptc_info = IptcImagePlugin.getiptcinfo(im) or {}
for tag, value in iptc_info.items():
- decoded = _iptc_tags.get(tag, "unknown")
- out["iptc." + decoded] = value
+ decoded = PhotoWebber._iptc_tags.get(tag, "unknown")
+ out["Iptc." + decoded] = value
+ print out
return out
@staticmethod

0 comments on commit fa461a8

Please sign in to comment.
Something went wrong with that request. Please try again.