From 0f20fc18af7b24bd95d5df1f52ba9c251cf3972d Mon Sep 17 00:00:00 2001 From: jevans Date: Mon, 3 Jun 2013 21:06:57 -0400 Subject: [PATCH] Starting Exif read support. --- glymur/jp2box.py | 69 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/glymur/jp2box.py b/glymur/jp2box.py index a435f67..f11674e 100644 --- a/glymur/jp2box.py +++ b/glymur/jp2box.py @@ -1618,6 +1618,8 @@ class UUIDBox(Jp2kBox): else: text = buffer.decode('utf-8') kwargs['data'] = ET.fromstring(text) + elif kwargs['uuid'].bytes == b'JpgTiffExif->JP2': + kwargs['data'] = _parse_exif(buffer) else: kwargs['data'] = buffer box = UUIDBox(**kwargs) @@ -1666,6 +1668,73 @@ def _indent(elem, level=0): if level and (not elem.tail or not elem.tail.strip()): elem.tail = i +_tagnum2name = {271: 'Make', 272: 'Model', + 282: 'XResolution', 283: 'YResolution', + 296: 'ResolutionUnit', + 531: 'YCbCrPositioning', + 34665: 'ExifTag', + 34853: 'GPSTag'} + +def _parse_exif(buffer): + """Interpret raw buffer consisting of Exif IFD. + """ + # Ignore the first six bytes. + # Next six should be (73, 73, 42, 8, numtags) + data = struct.unpack('