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

Expand tag support for Nikon #141

Open
wants to merge 9 commits 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
32 changes: 28 additions & 4 deletions exifread/classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,25 +250,49 @@ def _process_tag(self, ifd, ifd_name: str, tag_entry, entry, tag: int, tag_name,
printable = str(values[0:-1])
else:
printable = str(values)

# compute printable version of values
if tag_entry:
# optional 2nd tag element is present
if len(tag_entry) != 1:
if callable(tag_entry[1]):
# call mapping function
printable = tag_entry[1](values)
# Tag with SubIFDs
elif isinstance(tag_entry[1], tuple):
ifd_info = tag_entry[1]
try:
logger.debug('%s SubIFD at offset %d:', ifd_info[0], values[0])
self.dump_ifd(values[0], ifd_info[0], tag_dict=ifd_info[1], stop_tag=stop_tag)
except IndexError:
logger.warning('No values found for %s SubIFD', ifd_info[0])
elif isinstance(values, list):
# A list can be a list of the same type of value or a list of values with a
# different meaning by position.

pretty_values = []
if isinstance(tag_entry[1], list):
for _i in range(len(values)):
pretty_values.append(tag_entry[1][_i].get(values[_i], repr(values[_i])))
else:
for val in values:
pretty_values.append(tag_entry[1].get(val, repr(val)))

# FIXME: with the exception of ASCII fields `values` will always be a list.
# We have no way of knowing if the field is a single value or list of
# values. Also not sure if we know the difference between an empty list and
# an empty field value. We just do our best here.
if len(pretty_values) > 1:
printable = str(pretty_values)
elif len(pretty_values) == 1:
printable = str(pretty_values[0])
else:
printable = ''

else:
printable = ''
for val in values:
# use lookup table for this tag
printable += tag_entry[1].get(val, repr(val))
# NOTE: We shouldn't make it here. This would mean we received an ASCII
# value to be used in a lookup table it is possible.
printable = tag_entry[1].get(val, repr(values))

self.tags[ifd_name + ' ' + tag_name] = IfdTag(
printable, tag, field_type, values, field_offset, count * type_length
Expand Down
17 changes: 15 additions & 2 deletions exifread/tags/exif.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@
1: 'Regenerated',
2: 'Unclean'
}),
0x014A: ('SubIFDs', ),
0x0148: ('ConsecutiveBadFaxLines', ),
0x014C: ('InkSet', {
1: 'CMYK',
Expand All @@ -207,9 +208,10 @@
0x0155: ('SMaxSampleValue', ),
0x0156: ('TransferRange', ),
0x0157: ('ClipPath', ),
0x015B: ('JPEGTables', ),
0x0200: ('JPEGProc', ),
0x0201: ('JPEGInterchangeFormat', ),
0x0202: ('JPEGInterchangeFormatLength', ),
0x0201: ('JPEGInterchangeFormat', ), # JpegIFOffset
0x0202: ('JPEGInterchangeFormatLength', ), # JpegIFByteCount
0x0211: ('YCbCrCoefficients', ),
0x0212: ('YCbCrSubSampling', ),
0x0213: ('YCbCrPositioning', {
Expand Down Expand Up @@ -243,6 +245,9 @@
0x8825: ('GPSInfo', GPS_INFO), # GPS tags
0x8827: ('ISOSpeedRatings', ),
0x8828: ('OECF', ),
0x8829: ('Interlace', ),
0x882A: ('TimeZoneOffset', ),
0x882B: ('SelfTimerMode', ),
0x8830: ('SensitivityType', {
0: 'Unknown',
1: 'Standard Output Sensitivity',
Expand Down Expand Up @@ -335,7 +340,15 @@
95: 'Flash fired, auto mode, return light detected, red-eye reduction mode'
}),
0x920A: ('FocalLength', ),
0x920B: ('FlashEnergy', ),
0x920C: ('SpatialFrequencyResponse', ),
0x920D: ('Noise', ),
0x9211: ('ImageNumber', ),
0x9212: ('SecurityClassification', ),
0x9213: ('ImageHistory', ),
0x9214: ('SubjectArea', ),
0x9215: ('ExposureIndex', ),
0x9216: ('TIFF/EPStandardID', ),
0x927C: ('MakerNote', ),
0x9286: ('UserComment', make_string_uc),
0x9290: ('SubSecTime', ),
Expand Down
Loading