Merge branch 'master' into devel

This commit is contained in:
John Evans 2013-06-07 07:56:08 -04:00
commit 8c250013c8
5 changed files with 45 additions and 46 deletions

View file

@ -1,3 +1,6 @@
Jun 06, 2013 - v0.1.6 Exif classes made private. Refactored IFD post
processing. Corrected omission of Exif in UUIDBox docstring.
Jun 06, 2013 - v0.1.5 Changed ColourSpecificationBox attribute "color_space" Jun 06, 2013 - v0.1.5 Changed ColourSpecificationBox attribute "color_space"
to "colorspace". Fixed MANIFEST issue affecting PyPI installs. to "colorspace". Fixed MANIFEST issue affecting PyPI installs.

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.5' release = '0.1.6'
# 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

@ -142,18 +142,25 @@ From this point forward, python3 will be referred to as just "python".
Installation Installation
============ ============
First, get the code by going to either of You can install glymur via pip from the command line::
$ pip install glymur
or manually retrieve the code from either of GitHub or PyPI
* https://pypi.python.org/pypi/Glymur/ (stable releases) * https://pypi.python.org/pypi/Glymur/ (stable releases)
* http://github.com/quintusdias/glymur (bleeding edge) * http://github.com/quintusdias/glymur (bleeding edge)
and then unpack and install with::
$ python setup.py install --prefix=/install/path
In addition to merely installing glymur, you should adjust your **$PATH** In addition to merely installing glymur, you should adjust your **$PATH**
environment variable in order to be able to use the *jp2dump* script from environment variable in order to be able to use the *jp2dump* script from
the unix command line. the unix command line.
:: ::
$ python setup.py install --prefix=/install/path
$ export PYTHONPATH=/install/path/lib/python3.3/site-packages $ export PYTHONPATH=/install/path/lib/python3.3/site-packages
$ export PATH=/install/path/bin:$PATH $ export PATH=/install/path/bin:$PATH

View file

@ -1669,28 +1669,28 @@ class Exif:
offset = data[3] offset = data[3]
# This is the 'Exif Image' portion. # This is the 'Exif Image' portion.
exif = ExifImageIfd(self.endian, buffer[6:], offset) exif = _ExifImageIfd(self.endian, buffer[6:], offset)
self.exif_image = exif.ifd self.exif_image = exif.processed_ifd
if 'ExifTag' in self.exif_image.keys(): if 'ExifTag' in self.exif_image.keys():
offset = self.exif_image['ExifTag'] offset = self.exif_image['ExifTag']
photo = ExifPhotoIfd(self.endian, buffer[6:], offset) photo = _ExifPhotoIfd(self.endian, buffer[6:], offset)
self.exif_photo = photo.ifd self.exif_photo = photo.processed_ifd
if 'InteroperabilityTag' in self.exif_photo.keys(): if 'InteroperabilityTag' in self.exif_photo.keys():
offset = self.exif_photo['InteroperabilityTag'] offset = self.exif_photo['InteroperabilityTag']
interop = ExifInteroperabilityIfd(self.endian, interop = _ExifInteroperabilityIfd(self.endian,
buffer[6:], buffer[6:],
offset) offset)
self.iop = interop.ifd self.iop = interop.processed_ifd
if 'GPSTag' in self.exif_image.keys(): if 'GPSTag' in self.exif_image.keys():
offset = self.exif_image['GPSTag'] offset = self.exif_image['GPSTag']
gps = ExifGPSInfoIfd(self.endian, buffer[6:], offset) gps = _ExifGPSInfoIfd(self.endian, buffer[6:], offset)
self.exif_gpsinfo = gps.ifd self.exif_gpsinfo = gps.processed_ifd
class Ifd: class _Ifd:
""" """
Attributes Attributes
---------- ----------
@ -1705,6 +1705,8 @@ class Ifd:
Number of tags in the IFD. Number of tags in the IFD.
raw_ifd : dictionary raw_ifd : dictionary
Maps tag number to "mildly-interpreted" tag value. Maps tag number to "mildly-interpreted" tag value.
processed_ifd : dictionary
Maps tag name to "mildly-interpreted" tag value.
""" """
datatype2fmt = {1: ('B', 1), datatype2fmt = {1: ('B', 1),
2: ('B', 1), 2: ('B', 1),
@ -1718,6 +1720,7 @@ class Ifd:
def __init__(self, endian, buffer, offset): def __init__(self, endian, buffer, offset):
self.endian = endian self.endian = endian
self.buffer = buffer self.buffer = buffer
self.processed_ifd = {}
self.num_tags, = struct.unpack(endian + 'H', self.num_tags, = struct.unpack(endian + 'H',
buffer[offset:offset + 2]) buffer[offset:offset + 2])
@ -1774,8 +1777,13 @@ class Ifd:
return payload return payload
def post_process(self, tagnum2name):
for tag, value in self.raw_ifd.items():
tag_name = tagnum2name[tag]
self.processed_ifd[tag_name] = value
class ExifImageIfd(Ifd):
class _ExifImageIfd(_Ifd):
""" """
Attributes Attributes
---------- ----------
@ -1990,16 +1998,11 @@ class ExifImageIfd(Ifd):
51041: 'NoiseProfile'} 51041: 'NoiseProfile'}
def __init__(self, endian, buffer, offset): def __init__(self, endian, buffer, offset):
Ifd.__init__(self, endian, buffer, offset) _Ifd.__init__(self, endian, buffer, offset)
self.post_process(self.tagnum2name)
# Now post process the raw IFD.
self.ifd = {}
for tag, value in self.raw_ifd.items():
tag_name = self.tagnum2name[tag]
self.ifd[tag_name] = value
class ExifPhotoIfd(Ifd): class _ExifPhotoIfd(_Ifd):
tagnum2name = {33434: 'ExposureTime', tagnum2name = {33434: 'ExposureTime',
33437: 'FNumber', 33437: 'FNumber',
34850: 'ExposureProgram', 34850: 'ExposureProgram',
@ -2071,16 +2074,11 @@ class ExifPhotoIfd(Ifd):
42037: 'LensSerialNumber'} 42037: 'LensSerialNumber'}
def __init__(self, endian, buffer, offset): def __init__(self, endian, buffer, offset):
Ifd.__init__(self, endian, buffer, offset) _Ifd.__init__(self, endian, buffer, offset)
self.post_process(self.tagnum2name)
# Now post process the raw IFD.
self.ifd = {}
for tag, value in self.raw_ifd.items():
tag_name = self.tagnum2name[tag]
self.ifd[tag_name] = value
class ExifGPSInfoIfd(Ifd): class _ExifGPSInfoIfd(_Ifd):
tagnum2name = {0: 'GPSVersionID', tagnum2name = {0: 'GPSVersionID',
1: 'GPSLatitudeRef', 1: 'GPSLatitudeRef',
2: 'GPSLatitude', 2: 'GPSLatitude',
@ -2114,16 +2112,11 @@ class ExifGPSInfoIfd(Ifd):
30: 'GPSDifferential'} 30: 'GPSDifferential'}
def __init__(self, endian, buffer, offset): def __init__(self, endian, buffer, offset):
Ifd.__init__(self, endian, buffer, offset) _Ifd.__init__(self, endian, buffer, offset)
self.post_process(self.tagnum2name)
# Now post process the raw IFD.
self.ifd = {}
for tag, value in self.raw_ifd.items():
tag_name = self.tagnum2name[tag]
self.ifd[tag_name] = value
class ExifInteroperabilityIfd(Ifd): class _ExifInteroperabilityIfd(_Ifd):
tagnum2name = {1: 'InteroperabilityIndex', tagnum2name = {1: 'InteroperabilityIndex',
2: 'InteroperabilityVersion', 2: 'InteroperabilityVersion',
4096: 'RelatedImageFileFormat', 4096: 'RelatedImageFileFormat',
@ -2131,13 +2124,9 @@ class ExifInteroperabilityIfd(Ifd):
4098: 'RelatedImageLength'} 4098: 'RelatedImageLength'}
def __init__(self, endian, buffer, offset): def __init__(self, endian, buffer, offset):
Ifd.__init__(self, endian, buffer, offset) _Ifd.__init__(self, endian, buffer, offset)
self.post_process(self.tagnum2name)
# Now post process the raw IFD.
self.ifd = {}
for tag, value in self.raw_ifd.items():
tag_name = self.tagnum2name[tag]
self.ifd[tag_name] = value
# Map each box ID to the corresponding class. # Map each box ID to the corresponding class.
_box_with_id = { _box_with_id = {

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.5', 'version': '0.1.6',
'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',