diff --git a/CHANGES.txt b/CHANGES.txt index 056f3a9..2cb6883 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,3 +1,6 @@ +Jun 07, 2013 - v0.1.7 Changed Exif dictionary names from ['Exif', 'Photo', + 'Iop', 'GPSInfo'] to ['Image', 'Photo', 'Iop', 'GPSInfo']. + Jun 06, 2013 - v0.1.6 Exif classes made private. Refactored IFD post processing. Corrected omission of Exif in UUIDBox docstring. diff --git a/docs/source/conf.py b/docs/source/conf.py index 31eba3d..262e5d8 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -78,7 +78,7 @@ copyright = u'2013, John Evans' # The short X.Y version. version = '0.1' # The full version, including alpha/beta/rc tags. -release = '0.1.6' +release = '0.1.7' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/docs/source/introduction.rst b/docs/source/introduction.rst index 7f3a5ed..27beed2 100644 --- a/docs/source/introduction.rst +++ b/docs/source/introduction.rst @@ -187,7 +187,7 @@ Testing In order to run all of the test suite, you will first need the OpenJPEG test data that you previously retrieved. Then you should set the **OPJ_DATA_ROOT** environment variable to -point to this directory, e.g.:: +point to this directory, e.g. :: $ cd /somewhere/outside/the/glymur/unpacking/directory $ svn co http://openjpeg.googlecode.com/svn/data @@ -203,5 +203,5 @@ OpenJPEG counterparts are already failing, and others which do pass but still produce heaps of output on stderr. Rather than let this swamp the signal (that most of the tests are actually passing), they've been filtered out for now. There are also more skipped tests on Python 2.7 -than on Python 3.3. The important point to remember is whether or not any test +than on Python 3.3. The important part is whether or not any test errors are reported at the end. diff --git a/glymur/jp2box.py b/glymur/jp2box.py index 789c803..e8e7678 100644 --- a/glymur/jp2box.py +++ b/glymur/jp2box.py @@ -1626,7 +1626,7 @@ class UUIDBox(Jp2kBox): elif kwargs['uuid'].bytes == b'JpgTiffExif->JP2': e = Exif(buffer) d = {} - d['Exif'] = e.exif_image + d['Image'] = e.exif_image d['Photo'] = e.exif_photo d['GPSInfo'] = e.exif_gpsinfo d['Iop'] = e.exif_iop @@ -1779,7 +1779,13 @@ class _Ifd: def post_process(self, tagnum2name): for tag, value in self.raw_ifd.items(): - tag_name = tagnum2name[tag] + try: + tag_name = tagnum2name[tag] + except KeyError: + # Ok, we don't recognize this tag. Just use the numeric id. + msg = 'Unrecognized Exif tag "{0}".'.format(tag) + warnings.warn(msg, UserWarning) + tag_name = tag self.processed_ifd[tag_name] = value diff --git a/glymur/test/test_jp2k.py b/glymur/test/test_jp2k.py index a32cda8..5e9ab9b 100644 --- a/glymur/test/test_jp2k.py +++ b/glymur/test/test_jp2k.py @@ -4,6 +4,7 @@ import doctest import imp import os import re +import shutil import struct import sys import tempfile @@ -658,5 +659,37 @@ class TestJp2k(unittest.TestCase): attr_value = elt.attrib['{0}CreatorTool'.format(ns1)] self.assertEqual(attr_value, 'glymur') + def test_unrecognized_exif_tag(self): + # An unrecognized exif tag should be handled gracefully. + with tempfile.NamedTemporaryFile(suffix='.jp2') as tfile: + shutil.copyfile(self.jp2file, tfile.name) + + # The Exif UUID starts at byte 77. There are 8 bytes for the L and + # T fields, then 16 bytes for the UUID identifier, then 6 exif + # header bytes, then 8 bytes for the TIFF header, then 2 bytes + # the the Image IFD number of tags, where we finally find the first + # tag, "Make" (271). We'll corrupt it by changing it into 171, + # which does not correspond to any known Exif Image tag. + with open(tfile.name, 'r+b') as fp: + fp.seek(117) + buffer = struct.pack('