Fix errors and add tags to mapping

This commit is contained in:
Michał Gdula 2023-04-09 15:25:34 +00:00
parent 26a081be3e
commit 8e8bee800e
2 changed files with 81 additions and 42 deletions

View file

@ -50,9 +50,11 @@ def focal_length(value):
Formats the focal length into a standard format Formats the focal length into a standard format
""" """
try: try:
return str(value[0] / value[1]) + "mm" calculated = value[0] / value[1]
except TypeError: except TypeError:
return str(value) + "mm" calculated = value
return str(round(calculated, 1)) + " mm"
def exposure(value): def exposure(value):
@ -66,7 +68,11 @@ def color_space(value):
""" """
Maps the value of the color space to a human readable format Maps the value of the color space to a human readable format
""" """
value_map = {0: "Reserved", 1: "sRGB", 65535: "Uncalibrated"} value_map = {
0: "Reserved",
1: "sRGB",
65535: "Uncalibrated"
}
try: try:
return value_map[int(value)] return value_map[int(value)]
except KeyError: except KeyError:
@ -78,28 +84,28 @@ def flash(value):
Maps the value of the flash to a human readable format Maps the value of the flash to a human readable format
""" """
value_map = { value_map = {
0: "Flash did not fire", 0: "Did not fire",
1: "Flash fired", 1: "Fired",
5: "Strobe return light not detected", 5: "Strobe return light not detected",
7: "Strobe return light detected", 7: "Strobe return light detected",
9: "Flash fired, compulsory flash mode", 9: "Fired, compulsory",
13: "Flash fired, compulsory flash mode, return light not detected", 13: "Fired, compulsory, return light not detected",
15: "Flash fired, compulsory flash mode, return light detected", 15: "Fired, compulsory, return light detected",
16: "Flash did not fire, compulsory flash mode", 16: "Did not fire, compulsory",
24: "Flash did not fire, auto mode", 24: "Did not fire, auto mode",
25: "Flash fired, auto mode", 25: "Fired, auto mode",
29: "Flash fired, auto mode, return light not detected", 29: "Fired, auto mode, return light not detected",
31: "Flash fired, auto mode, return light detected", 31: "Fired, auto mode, return light detected",
32: "No flash function", 32: "No function",
65: "Flash fired, red-eye reduction mode", 65: "Fired, red-eye reduction mode",
69: "Flash fired, red-eye reduction mode, return light not detected", 69: "Fired, red-eye reduction mode, return light not detected",
71: "Flash fired, red-eye reduction mode, return light detected", 71: "Fired, red-eye reduction mode, return light detected",
73: "Flash fired, compulsory flash mode, red-eye reduction mode", 73: "Fired, compulsory, red-eye reduction mode",
77: "Flash fired, compulsory flash mode, red-eye reduction mode, return light not detected", 77: "Fired, compulsory, red-eye reduction mode, return light not detected",
79: "Flash fired, compulsory flash mode, red-eye reduction mode, return light detected", 79: "Fired, compulsory, red-eye reduction mode, return light detected",
89: "Flash fired, auto mode, red-eye reduction mode", 89: "Fired, auto mode, red-eye reduction mode",
93: "Flash fired, auto mode, return light not detected, red-eye reduction mode", 93: "Fired, auto mode, return light not detected, red-eye reduction mode",
95: "Flash fired, auto mode, return light detected, red-eye reduction mode", 95: "Fired, auto mode, return light detected, red-eye reduction mode",
} }
try: try:
return value_map[int(value)] return value_map[int(value)]
@ -152,7 +158,11 @@ def resolution_unit(value):
""" """
Maps the value of the resolution unit to a human readable format Maps the value of the resolution unit to a human readable format
""" """
value_map = {1: "No absolute unit of measurement", 2: "Inch", 3: "Centimeter"} value_map = {
1: "No absolute unit of measurement",
2: "Inch",
3: "Centimeter"
}
try: try:
return value_map[int(value)] return value_map[int(value)]
except KeyError: except KeyError:
@ -213,8 +223,8 @@ def white_balance(value):
Maps the value of the white balance to a human readable format Maps the value of the white balance to a human readable format
""" """
value_map = { value_map = {
0: "Auto white balance", 0: "Auto",
1: "Manual white balance", 1: "Manual",
} }
try: try:
return value_map[int(value)] return value_map[int(value)]
@ -227,8 +237,8 @@ def exposure_mode(value):
Maps the value of the exposure mode to a human readable format Maps the value of the exposure mode to a human readable format
""" """
value_map = { value_map = {
0: "Auto exposure", 0: "Auto",
1: "Manual exposure", 1: "Manual",
2: "Auto bracket", 2: "Auto bracket",
} }
try: try:
@ -387,3 +397,30 @@ def pixel_dimension(value):
Maps the value of the pixel dimension to a human readable format Maps the value of the pixel dimension to a human readable format
""" """
return str(value) + " px" return str(value) + " px"
def title(value):
"""
Maps the value of the title to a human readable format
"""
return str(value.title())
def subject_distance(value):
"""
Maps the value of the subject distance to a human readable format
"""
return str(value) + " m"
def subject_distance_range(value):
"""
Maps the value of the subject distance range to a human readable format
"""
value_map = {
0: "Unknown",
1: "Macro",
2: "Close view",
3: "Distant view",
}
try:
return value_map[int(value)]
except KeyError:
return None

View file

@ -10,22 +10,22 @@ PHOTOGRAHER_MAPPING = {
"Copyright": ["Copyright"], "Copyright": ["Copyright"],
} }
CAMERA_MAPPING = { CAMERA_MAPPING = {
"Model": ["Model"], "Model": ["Model", "title"],
"Make": ["Make"], "Make": ["Manifacturer", "title"],
"BodySerialNumber": ["Camera Type"], "BodySerialNumber": ["Camera Type"],
"LensMake": ["Lens Make"], "LensMake": ["Lens Make", "title"],
"LenseModel": ["Lens Model"], "LensModel": ["Lens Model", "title"],
"LensSpecification": ["Lens Specification", "lens_specification"], "LensSpecification": ["Lens Specification", "lens_specification"],
"ComponentsConfiguration": ["Components Configuration", "components_configuration"], "ComponentsConfiguration": ["Components Configuration", "components_configuration"],
"DateTime": ["Date Processed", "date_format"], "DateTime": ["Date and Time", "date_format"],
"DateTimeDigitized": ["Time Digitized", "date_format"], "DateTimeOriginal": ["Date and Time (Original)", "date_format"],
"DateTimeDigitized": ["Date and Time (Digitized)", "date_format"],
"OffsetTime": ["Time Offset"], "OffsetTime": ["Time Offset"],
"OffsetTimeOriginal": ["Time Offset - Original"], "OffsetTimeOriginal": ["Time Offset (Original)"],
"OffsetTimeDigitized": ["Time Offset - Digitized"], "OffsetTimeDigitized": ["Time Offset (Digitized)"],
"DateTimeOriginal": ["Date Original", "date_format"], "FNumber": ["FNumber", "fnumber"],
"FNumber": ["F-Stop", "fnumber"],
"FocalLength": ["Focal Length", "focal_length"], "FocalLength": ["Focal Length", "focal_length"],
"FocalLengthIn35mmFilm": ["Focal Length (35mm format)", "focal_length"], "FocalLengthIn35mmFilm": ["Focal Length in 35mm format", "focal_length"],
"MaxApertureValue": ["Max Aperture", "fnumber"], "MaxApertureValue": ["Max Aperture", "fnumber"],
"ApertureValue": ["Aperture", "fnumber"], "ApertureValue": ["Aperture", "fnumber"],
"ShutterSpeedValue": ["Shutter Speed", "shutter"], "ShutterSpeedValue": ["Shutter Speed", "shutter"],
@ -41,6 +41,8 @@ CAMERA_MAPPING = {
"MeteringMode": ["Metering Mode", "metering_mode"], "MeteringMode": ["Metering Mode", "metering_mode"],
"LightSource": ["Light Source", "light_source"], "LightSource": ["Light Source", "light_source"],
"SceneCaptureType": ["Scene Capture Type", "scene_capture_type"], "SceneCaptureType": ["Scene Capture Type", "scene_capture_type"],
"SubjectDistance": ["Subject Distance", "subject_distance"],
"SubjectDistanceRange": ["Subject Distance Range", "subject_distance_range"],
} }
SOFTWARE_MAPPING = { SOFTWARE_MAPPING = {
"Software": ["Software"], "Software": ["Software"],