Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Canon MakerNote: Allow callable to process tag value #189

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion exifread/classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,10 @@ def _canon_decode_tag(self, value, mn_tags):
tag = mn_tags.get(i, ('Unknown', ))
name = tag[0]
if len(tag) > 1:
val = tag[1].get(value[i], 'Unknown')
if callable(tag[1]):
val = tag[1](value[i])
else:
val = tag[1].get(value[i], 'Unknown')
else:
val = value[i]
try:
Expand Down
23 changes: 12 additions & 11 deletions exifread/tags/makernote/canon.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@
http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Canon.html
"""

def add_one(value):
return value + 1


def subtract_one(value):
return value - 1


def convert_temp(value):
return '%d C' % (value - 128)

TAGS = {
0x0003: ('FlashInfo',),
0x0006: ('ImageType', ),
Expand Down Expand Up @@ -538,6 +549,7 @@
3: 'None'
}),
9: ('SequenceNumber', ),
12: ('CameraTemperature', convert_temp),
14: ('AFPointUsed', ),
15: ('FlashBias', {
0xFFC0: '-2 EV',
Expand Down Expand Up @@ -659,17 +671,6 @@
}


def add_one(value):
return value + 1


def subtract_one(value):
return value - 1


def convert_temp(value):
return '%d C' % (value - 128)

# CameraInfo data structures have variable sized members. Each entry here is:
# byte offset: (item name, data item type, decoding map).
# Note that the data item type is fed directly to struct.unpack at the
Expand Down
Loading