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.
|
thumbnail.
|
||||||
|
|
||||||
Jun 07, 2013 - v0.1.7 Changed Exif dictionary names from ['Exif', 'Photo',
|
Jun 07, 2013 - v0.1.7 Changed Exif dictionary names from ['Exif', 'Photo',
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ References
|
||||||
Extensions
|
Extensions
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import collections
|
||||||
import copy
|
import copy
|
||||||
import datetime
|
import datetime
|
||||||
import math
|
import math
|
||||||
|
|
@ -1713,8 +1714,8 @@ class UUIDBox(Jp2kBox):
|
||||||
more verbose description of the box.
|
more verbose description of the box.
|
||||||
uuid : uuid.UUID
|
uuid : uuid.UUID
|
||||||
16-byte UUID
|
16-byte UUID
|
||||||
data : bytes or dictionary or ElementTree.Element
|
data : bytes or dict or ElementTree.Element
|
||||||
Vendor-specific UUID data. Exif UUIDs are interpreted as dictionaries.
|
Vendor-specific data. Exif UUIDs are interpreted as dictionaries.
|
||||||
XMP UUIDs are interpreted as standard XML.
|
XMP UUIDs are interpreted as standard XML.
|
||||||
"""
|
"""
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
|
|
@ -1782,7 +1783,7 @@ class UUIDBox(Jp2kBox):
|
||||||
kwargs['data'] = ET.fromstring(text)
|
kwargs['data'] = ET.fromstring(text)
|
||||||
elif kwargs['uuid'].bytes == b'JpgTiffExif->JP2':
|
elif kwargs['uuid'].bytes == b'JpgTiffExif->JP2':
|
||||||
e = Exif(buffer)
|
e = Exif(buffer)
|
||||||
d = {}
|
d = collections.OrderedDict()
|
||||||
d['Image'] = 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
|
||||||
|
|
@ -1877,7 +1878,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.processed_ifd = collections.OrderedDict()
|
||||||
|
|
||||||
self.num_tags, = struct.unpack(endian + 'H',
|
self.num_tags, = struct.unpack(endian + 'H',
|
||||||
buffer[offset:offset + 2])
|
buffer[offset:offset + 2])
|
||||||
|
|
@ -1885,7 +1886,7 @@ class _Ifd:
|
||||||
fmt = self.endian + 'HHII' * self.num_tags
|
fmt = self.endian + 'HHII' * self.num_tags
|
||||||
ifd_buffer = buffer[offset + 2:offset + 2 + self.num_tags * 12]
|
ifd_buffer = buffer[offset + 2:offset + 2 + self.num_tags * 12]
|
||||||
data = struct.unpack(fmt, ifd_buffer)
|
data = struct.unpack(fmt, ifd_buffer)
|
||||||
self.raw_ifd = {}
|
self.raw_ifd = collections.OrderedDict()
|
||||||
for j, tag in enumerate(data[0::4]):
|
for j, tag in enumerate(data[0::4]):
|
||||||
# The offset to the tag offset/payload is the offset to the IFD
|
# 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
|
# 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)",
|
lines = ["UUID Box (uuid) @ (77, 638)",
|
||||||
" UUID: 4a706754-6966-6645-7869-662d3e4a5032 (Exif)",
|
" UUID: 4a706754-6966-6645-7869-662d3e4a5032 (Exif)",
|
||||||
" UUID Data: ",
|
" UUID Data: ",
|
||||||
"{'GPSInfo': {'GPSAltitude': 0.0,",
|
"{'Image': {'Make': 'HTC',",
|
||||||
" 'GPSAltitudeRef': 0,",
|
" 'Model': 'HTC Glacier',",
|
||||||
" 'GPSDateStamp': '2013:02:09',",
|
" 'XResolution': 72.0,",
|
||||||
" 'GPSLatitude': [42.0, 20.0, 33.61],",
|
" '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',",
|
" 'GPSLatitudeRef': 'N',",
|
||||||
" 'GPSLongitude': [71.0, 5.0, 17.32],",
|
" 'GPSLatitude': [42.0, 20.0, 33.61],",
|
||||||
" 'GPSLongitudeRef': 'W',",
|
" 'GPSLongitudeRef': 'W',",
|
||||||
|
" 'GPSLongitude': [71.0, 5.0, 17.32],",
|
||||||
|
" 'GPSAltitudeRef': 0,",
|
||||||
|
" 'GPSAltitude': 0.0,",
|
||||||
|
" 'GPSTimeStamp': [19.0, 47.0, 53.0],",
|
||||||
" 'GPSMapDatum': 'WGS-84',",
|
" 'GPSMapDatum': 'WGS-84',",
|
||||||
" 'GPSProcessingMethod': (65,",
|
" 'GPSProcessingMethod': (65,",
|
||||||
" 83,",
|
" 83,",
|
||||||
|
|
@ -860,28 +880,8 @@ class TestPrinting(unittest.TestCase):
|
||||||
" 79,",
|
" 79,",
|
||||||
" 82,",
|
" 82,",
|
||||||
" 75),",
|
" 75),",
|
||||||
" 'GPSTimeStamp': [19.0, 47.0, 53.0],",
|
" 'GPSDateStamp': '2013:02:09'},",
|
||||||
" 'GPSVersionID': (2, 2, 0)},",
|
" 'Iop': None}"]
|
||||||
" '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}}"]
|
|
||||||
|
|
||||||
expected = '\n'.join(lines)
|
expected = '\n'.join(lines)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue