Merge branch 'devel'

This commit is contained in:
John Evans 2013-06-07 08:54:49 -04:00
commit 9f90e397ea
7 changed files with 58 additions and 15 deletions

View file

@ -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 Jun 06, 2013 - v0.1.6 Exif classes made private. Refactored IFD post
processing. Corrected omission of Exif in UUIDBox docstring. processing. Corrected omission of Exif in UUIDBox docstring.

View file

@ -78,7 +78,7 @@ copyright = u'2013, John Evans'
# The short X.Y version. # The short X.Y version.
version = '0.1' version = '0.1'
# The full version, including alpha/beta/rc tags. # 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 # The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages. # for a list of supported languages.

View file

@ -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 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 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 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. errors are reported at the end.

View file

@ -1626,7 +1626,7 @@ class UUIDBox(Jp2kBox):
elif kwargs['uuid'].bytes == b'JpgTiffExif->JP2': elif kwargs['uuid'].bytes == b'JpgTiffExif->JP2':
e = Exif(buffer) e = Exif(buffer)
d = {} d = {}
d['Exif'] = e.exif_image d['Image'] = e.exif_image
d['Photo'] = e.exif_photo d['Photo'] = e.exif_photo
d['GPSInfo'] = e.exif_gpsinfo d['GPSInfo'] = e.exif_gpsinfo
d['Iop'] = e.exif_iop d['Iop'] = e.exif_iop
@ -1779,7 +1779,13 @@ class _Ifd:
def post_process(self, tagnum2name): def post_process(self, tagnum2name):
for tag, value in self.raw_ifd.items(): for tag, value in self.raw_ifd.items():
try:
tag_name = tagnum2name[tag] 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 self.processed_ifd[tag_name] = value

View file

@ -4,6 +4,7 @@ import doctest
import imp import imp
import os import os
import re import re
import shutil
import struct import struct
import sys import sys
import tempfile import tempfile
@ -658,5 +659,37 @@ class TestJp2k(unittest.TestCase):
attr_value = elt.attrib['{0}CreatorTool'.format(ns1)] attr_value = elt.attrib['{0}CreatorTool'.format(ns1)]
self.assertEqual(attr_value, 'glymur') 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('<H', int(171))
fp.write(buffer)
# Verify that a warning is issued, but only on python3.
# On python2, just suppress the warning.
if sys.hexversion < 0x03030000:
with warnings.catch_warnings():
warnings.simplefilter("ignore")
j = Jp2k(tfile.name)
else:
with self.assertWarns(UserWarning) as cw:
j = Jp2k(tfile.name)
exif = j.box[3].data
# Were the tag == 271, 'Make' would be in the keys instead.
self.assertTrue(171 in exif['Image'].keys())
self.assertFalse('Make' in exif['Image'].keys())
if __name__ == "__main__": if __name__ == "__main__":
unittest.main() unittest.main()

View file

@ -820,15 +820,7 @@ class TestPrinting(unittest.TestCase):
lines = ["UUID Box (uuid) @ (77, 638)", lines = ["UUID Box (uuid) @ (77, 638)",
" UUID: 4a706754-6966-6645-7869-662d3e4a5032 (Exif)", " UUID: 4a706754-6966-6645-7869-662d3e4a5032 (Exif)",
" UUID Data: ", " UUID Data: ",
"{'Exif': {'ExifTag': 138,", "{'GPSInfo': {'GPSAltitude': 0.0,",
" 'GPSTag': 354,",
" 'Make': 'HTC',",
" 'Model': 'HTC Glacier',",
" 'ResolutionUnit': 2,",
" 'XResolution': 72.0,",
" 'YCbCrPositioning': 1,",
" 'YResolution': 72.0},",
" 'GPSInfo': {'GPSAltitude': 0.0,",
" 'GPSAltitudeRef': 0,", " 'GPSAltitudeRef': 0,",
" 'GPSDateStamp': '2013:02:09',", " 'GPSDateStamp': '2013:02:09',",
" 'GPSLatitude': [42.0, 20.0, 33.61],", " 'GPSLatitude': [42.0, 20.0, 33.61],",
@ -853,6 +845,14 @@ class TestPrinting(unittest.TestCase):
" 75),", " 75),",
" 'GPSTimeStamp': [19.0, 47.0, 53.0],", " 'GPSTimeStamp': [19.0, 47.0, 53.0],",
" 'GPSVersionID': (2, 2, 0)},", " 'GPSVersionID': (2, 2, 0)},",
" 'Image': {'ExifTag': 138,",
" 'GPSTag': 354,",
" 'Make': 'HTC',",
" 'Model': 'HTC Glacier',",
" 'ResolutionUnit': 2,",
" 'XResolution': 72.0,",
" 'YCbCrPositioning': 1,",
" 'YResolution': 72.0},",
" 'Iop': None,", " 'Iop': None,",
" 'Photo': {'ColorSpace': 1,", " 'Photo': {'ColorSpace': 1,",
" 'ComponentsConfiguration': (1, 2, 3, 0),", " 'ComponentsConfiguration': (1, 2, 3, 0),",
@ -867,6 +867,7 @@ class TestPrinting(unittest.TestCase):
" 'PixelYDimension': 1424}}"] " 'PixelYDimension': 1424}}"]
expected = '\n'.join(lines) expected = '\n'.join(lines)
self.assertEqual(actual, expected) self.assertEqual(actual, expected)
if __name__ == "__main__": if __name__ == "__main__":

View file

@ -1,7 +1,7 @@
from distutils.core import setup from distutils.core import setup
kwargs = {'name': 'Glymur', kwargs = {'name': 'Glymur',
'version': '0.1.6', 'version': '0.1.7',
'description': 'Tools for accessing JPEG2000 files', 'description': 'Tools for accessing JPEG2000 files',
'long_description': open('README.md').read(), 'long_description': open('README.md').read(),
'author': 'John Evans', 'author': 'John Evans',