Skip to content

Commit

Permalink
Add DJI makernotes, extract_thumbnail parameter (#168)
Browse files Browse the repository at this point in the history
  • Loading branch information
pierotofy authored Jun 3, 2022
1 parent d71cc61 commit 51d5c5a
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 4 deletions.
6 changes: 6 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,12 @@ Pass the ``-q`` or ``--quick`` command line arguments, or as:
tags = exifread.process_file(f, details=False)
To process makernotes only, without extracting the thumbnail image (if any):

.. code-block:: python
tags = exifread.process_file(f, details=True, extract_thumbnail=False)
Stop at a Given Tag
===================

Expand Down
4 changes: 2 additions & 2 deletions exifread/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def _determine_type(fh: BinaryIO) -> tuple:

def process_file(fh: BinaryIO, stop_tag=DEFAULT_STOP_TAG,
details=True, strict=False, debug=False,
truncate_tags=True, auto_seek=True):
truncate_tags=True, auto_seek=True, extract_thumbnail=True):
"""
Process an image file (expects an open file object).
Expand Down Expand Up @@ -179,7 +179,7 @@ def process_file(fh: BinaryIO, stop_tag=DEFAULT_STOP_TAG,
hdr.decode_maker_note()

# extract thumbnails
if details and thumb_ifd:
if details and thumb_ifd and extract_thumbnail:
hdr.extract_tiff_thumbnail(thumb_ifd)
hdr.extract_jpeg_thumbnail()

Expand Down
9 changes: 8 additions & 1 deletion exifread/classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,14 @@ def decode_maker_note(self) -> None:
self.dump_ifd(0, 'MakerNote', tag_dict=makernote.apple.TAGS)
self.offset = offset
return


if make == 'DJI':
offset = self.offset
self.offset += note.field_offset
self.dump_ifd(0, 'MakerNote', tag_dict=makernote.dji.TAGS)
self.offset = offset
return

# Canon
if make == 'Canon':
self.dump_ifd(note.field_offset, 'MakerNote',
Expand Down
2 changes: 1 addition & 1 deletion exifread/tags/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from exifread.tags.exif import EXIF_TAGS
from exifread.tags.makernote import (
apple, canon, casio, fujifilm, nikon, olympus,
apple, canon, casio, fujifilm, nikon, olympus, dji
)

DEFAULT_STOP_TAG = 'UNDEF'
Expand Down
17 changes: 17 additions & 0 deletions exifread/tags/makernote/dji.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
"""
Makernote (proprietary) tag definitions for DJI cameras
Based on https://github.com/exiftool/exiftool/blob/master/lib/Image/ExifTool/DJI.pm
"""

TAGS = {
0x03: ('SpeedX', ),
0x04: ('SpeedY', ),
0x05: ('SpeedZ', ),
0x06: ('Pitch', ),
0x07: ('Yaw', ),
0x08: ('Roll', ),
0x09: ('CameraPitch', ),
0x0a: ('CameraYaw', ),
0x0b: ('CameraRoll', ),
}

0 comments on commit 51d5c5a

Please sign in to comment.