Exif dictionaries changed to ordered dict, #46
This commit is contained in:
parent
105e25821a
commit
decd07cbc3
3 changed files with 37 additions and 33 deletions
|
|
@ -1,4 +1,7 @@
|
|||
Jun 11, 2013 - v0.1.8 Added reduce=-1 option to get lowest resolution
|
||||
Jun 15, 2013 - v0.1.9 Reading ICC profile headers. Exif dictionaries changed
|
||||
to ordered dicts.
|
||||
|
||||
Jun 14, 2013 - v0.1.8 Added reduce=-1 option to get lowest resolution
|
||||
thumbnail.
|
||||
|
||||
Jun 07, 2013 - v0.1.7 Changed Exif dictionary names from ['Exif', 'Photo',
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ References
|
|||
Extensions
|
||||
"""
|
||||
|
||||
import collections
|
||||
import copy
|
||||
import datetime
|
||||
import math
|
||||
|
|
@ -1713,8 +1714,8 @@ class UUIDBox(Jp2kBox):
|
|||
more verbose description of the box.
|
||||
uuid : uuid.UUID
|
||||
16-byte UUID
|
||||
data : bytes or dictionary or ElementTree.Element
|
||||
Vendor-specific UUID data. Exif UUIDs are interpreted as dictionaries.
|
||||
data : bytes or dict or ElementTree.Element
|
||||
Vendor-specific data. Exif UUIDs are interpreted as dictionaries.
|
||||
XMP UUIDs are interpreted as standard XML.
|
||||
"""
|
||||
def __init__(self, **kwargs):
|
||||
|
|
@ -1782,7 +1783,7 @@ class UUIDBox(Jp2kBox):
|
|||
kwargs['data'] = ET.fromstring(text)
|
||||
elif kwargs['uuid'].bytes == b'JpgTiffExif->JP2':
|
||||
e = Exif(buffer)
|
||||
d = {}
|
||||
d = collections.OrderedDict()
|
||||
d['Image'] = e.exif_image
|
||||
d['Photo'] = e.exif_photo
|
||||
d['GPSInfo'] = e.exif_gpsinfo
|
||||
|
|
@ -1877,7 +1878,7 @@ class _Ifd:
|
|||
def __init__(self, endian, buffer, offset):
|
||||
self.endian = endian
|
||||
self.buffer = buffer
|
||||
self.processed_ifd = {}
|
||||
self.processed_ifd = collections.OrderedDict()
|
||||
|
||||
self.num_tags, = struct.unpack(endian + 'H',
|
||||
buffer[offset:offset + 2])
|
||||
|
|
@ -1885,7 +1886,7 @@ class _Ifd:
|
|||
fmt = self.endian + 'HHII' * self.num_tags
|
||||
ifd_buffer = buffer[offset + 2:offset + 2 + self.num_tags * 12]
|
||||
data = struct.unpack(fmt, ifd_buffer)
|
||||
self.raw_ifd = {}
|
||||
self.raw_ifd = collections.OrderedDict()
|
||||
for j, tag in enumerate(data[0::4]):
|
||||
# The offset to the tag offset/payload is the offset to the IFD
|
||||
# plus 2 bytes for the number of tags plus 12 bytes for each
|
||||
|
|
|
|||
|
|
@ -837,13 +837,33 @@ class TestPrinting(unittest.TestCase):
|
|||
lines = ["UUID Box (uuid) @ (77, 638)",
|
||||
" UUID: 4a706754-6966-6645-7869-662d3e4a5032 (Exif)",
|
||||
" UUID Data: ",
|
||||
"{'GPSInfo': {'GPSAltitude': 0.0,",
|
||||
" 'GPSAltitudeRef': 0,",
|
||||
" 'GPSDateStamp': '2013:02:09',",
|
||||
" 'GPSLatitude': [42.0, 20.0, 33.61],",
|
||||
"{'Image': {'Make': 'HTC',",
|
||||
" 'Model': 'HTC Glacier',",
|
||||
" 'XResolution': 72.0,",
|
||||
" 'YResolution': 72.0,",
|
||||
" 'ResolutionUnit': 2,",
|
||||
" 'YCbCrPositioning': 1,",
|
||||
" 'ExifTag': 138,",
|
||||
" 'GPSTag': 354},",
|
||||
" 'Photo': {'ISOSpeedRatings': 76,",
|
||||
" 'ExifVersion': (48, 50, 50, 48),",
|
||||
" 'DateTimeOriginal': '2013:02:09 14:47:53',",
|
||||
" 'DateTimeDigitized': '2013:02:09 14:47:53',",
|
||||
" 'ComponentsConfiguration': (1, 2, 3, 0),",
|
||||
" 'FocalLength': 3.53,",
|
||||
" 'FlashpixVersion': (48, 49, 48, 48),",
|
||||
" 'ColorSpace': 1,",
|
||||
" 'PixelXDimension': 2528,",
|
||||
" 'PixelYDimension': 1424,",
|
||||
" 'InteroperabilityTag': 324},",
|
||||
" 'GPSInfo': {'GPSVersionID': (2, 2, 0),",
|
||||
" 'GPSLatitudeRef': 'N',",
|
||||
" 'GPSLongitude': [71.0, 5.0, 17.32],",
|
||||
" 'GPSLatitude': [42.0, 20.0, 33.61],",
|
||||
" 'GPSLongitudeRef': 'W',",
|
||||
" 'GPSLongitude': [71.0, 5.0, 17.32],",
|
||||
" 'GPSAltitudeRef': 0,",
|
||||
" 'GPSAltitude': 0.0,",
|
||||
" 'GPSTimeStamp': [19.0, 47.0, 53.0],",
|
||||
" 'GPSMapDatum': 'WGS-84',",
|
||||
" 'GPSProcessingMethod': (65,",
|
||||
" 83,",
|
||||
|
|
@ -860,28 +880,8 @@ class TestPrinting(unittest.TestCase):
|
|||
" 79,",
|
||||
" 82,",
|
||||
" 75),",
|
||||
" 'GPSTimeStamp': [19.0, 47.0, 53.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,",
|
||||
" 'Photo': {'ColorSpace': 1,",
|
||||
" 'ComponentsConfiguration': (1, 2, 3, 0),",
|
||||
" 'DateTimeDigitized': '2013:02:09 14:47:53',",
|
||||
" 'DateTimeOriginal': '2013:02:09 14:47:53',",
|
||||
" 'ExifVersion': (48, 50, 50, 48),",
|
||||
" 'FlashpixVersion': (48, 49, 48, 48),",
|
||||
" 'FocalLength': 3.53,",
|
||||
" 'ISOSpeedRatings': 76,",
|
||||
" 'InteroperabilityTag': 324,",
|
||||
" 'PixelXDimension': 2528,",
|
||||
" 'PixelYDimension': 1424}}"]
|
||||
" 'GPSDateStamp': '2013:02:09'},",
|
||||
" 'Iop': None}"]
|
||||
|
||||
expected = '\n'.join(lines)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue