Skip to content

Commit 51d5c5a

Browse files
authored
Add DJI makernotes, extract_thumbnail parameter (#168)
1 parent d71cc61 commit 51d5c5a

File tree

5 files changed

+34
-4
lines changed

5 files changed

+34
-4
lines changed

README.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,12 @@ Pass the ``-q`` or ``--quick`` command line arguments, or as:
121121
122122
tags = exifread.process_file(f, details=False)
123123
124+
To process makernotes only, without extracting the thumbnail image (if any):
125+
126+
.. code-block:: python
127+
128+
tags = exifread.process_file(f, details=True, extract_thumbnail=False)
129+
124130
Stop at a Given Tag
125131
===================
126132

exifread/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def _determine_type(fh: BinaryIO) -> tuple:
122122

123123
def process_file(fh: BinaryIO, stop_tag=DEFAULT_STOP_TAG,
124124
details=True, strict=False, debug=False,
125-
truncate_tags=True, auto_seek=True):
125+
truncate_tags=True, auto_seek=True, extract_thumbnail=True):
126126
"""
127127
Process an image file (expects an open file object).
128128
@@ -179,7 +179,7 @@ def process_file(fh: BinaryIO, stop_tag=DEFAULT_STOP_TAG,
179179
hdr.decode_maker_note()
180180

181181
# extract thumbnails
182-
if details and thumb_ifd:
182+
if details and thumb_ifd and extract_thumbnail:
183183
hdr.extract_tiff_thumbnail(thumb_ifd)
184184
hdr.extract_jpeg_thumbnail()
185185

exifread/classes.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,14 @@ def decode_maker_note(self) -> None:
496496
self.dump_ifd(0, 'MakerNote', tag_dict=makernote.apple.TAGS)
497497
self.offset = offset
498498
return
499-
499+
500+
if make == 'DJI':
501+
offset = self.offset
502+
self.offset += note.field_offset
503+
self.dump_ifd(0, 'MakerNote', tag_dict=makernote.dji.TAGS)
504+
self.offset = offset
505+
return
506+
500507
# Canon
501508
if make == 'Canon':
502509
self.dump_ifd(note.field_offset, 'MakerNote',

exifread/tags/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from exifread.tags.exif import EXIF_TAGS
66
from exifread.tags.makernote import (
7-
apple, canon, casio, fujifilm, nikon, olympus,
7+
apple, canon, casio, fujifilm, nikon, olympus, dji
88
)
99

1010
DEFAULT_STOP_TAG = 'UNDEF'

exifread/tags/makernote/dji.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
"""
2+
Makernote (proprietary) tag definitions for DJI cameras
3+
4+
Based on https://github.com/exiftool/exiftool/blob/master/lib/Image/ExifTool/DJI.pm
5+
"""
6+
7+
TAGS = {
8+
0x03: ('SpeedX', ),
9+
0x04: ('SpeedY', ),
10+
0x05: ('SpeedZ', ),
11+
0x06: ('Pitch', ),
12+
0x07: ('Yaw', ),
13+
0x08: ('Roll', ),
14+
0x09: ('CameraPitch', ),
15+
0x0a: ('CameraYaw', ),
16+
0x0b: ('CameraRoll', ),
17+
}

0 commit comments

Comments
 (0)