From 725cb85cdb0137e3db7d46edadd130b6a5980e5a Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Mon, 27 Jun 2011 17:12:59 -0400 Subject: [PATCH] Add more exif types, thanks to the imageinfo javascript plugin in some random google chrome demo extension. --- scanner/PhotoAlbum.py | 17 +++++++++++++++++ web/js/011-display.js | 4 ++++ 2 files changed, 21 insertions(+) diff --git a/scanner/PhotoAlbum.py b/scanner/PhotoAlbum.py index 35b2ca1..78bdb63 100644 --- a/scanner/PhotoAlbum.py +++ b/scanner/PhotoAlbum.py @@ -187,12 +187,25 @@ class Photo(object): raise except: pass + if "LightSource" in exif and exif["LightSource"] in self._metadata.light_source_dictionary: + try: + self._attributes["lightSource"] = self._metadata.light_source_dictionary[exif["LightSource"]] + except KeyboardInterrupt: + raise + except: + pass if "ExposureProgram" in exif and exif["ExposureProgram"] < len(self._metadata.exposure_list): self._attributes["exposureProgram"] = self._metadata.exposure_list[exif["ExposureProgram"]] if "SpectralSensitivity" in exif: self._attributes["spectralSensitivity"] = exif["SpectralSensitivity"] if "MeteringMode" in exif and exif["MeteringMode"] < len(self._metadata.metering_list): self._attributes["meteringMode"] = self._metadata.metering_list[exif["MeteringMode"]] + if "SensingMethod" in exif and exif["SensingMethod"] < len(self._metadata.sensing_method_list): + self._attributes["sensingMethod"] = self._metadata.sensing_method_list[exif["SensingMethod"]] + if "SceneCaptureType" in exif and exif["SceneCaptureType"] < len(self._metadata.scene_capture_type_list): + self._attributes["sceneCaptureType"] = self._metadata.scene_capture_type_list[exif["SceneCaptureType"]] + if "SubjectDistanceRange" in exif and exif["SubjectDistanceRange"] < len(self._metadata.subject_distance_range_list): + self._attributes["subjectDistanceRange"] = self._metadata.subject_distance_range_list[exif["SubjectDistanceRange"]] if "ExposureCompensation" in exif: self._attributes["exposureCompensation"] = exif["ExposureCompensation"] if "ExposureBiasValue" in exif: @@ -203,9 +216,13 @@ class Photo(object): self._attributes["dateTime"] = exif["DateTime"] _metadata.flash_dictionary = {0x0: "No Flash", 0x1: "Fired",0x5: "Fired, Return not detected",0x7: "Fired, Return detected",0x8: "On, Did not fire",0x9: "On, Fired",0xd: "On, Return not detected",0xf: "On, Return detected",0x10: "Off, Did not fire",0x14: "Off, Did not fire, Return not detected",0x18: "Auto, Did not fire",0x19: "Auto, Fired",0x1d: "Auto, Fired, Return not detected",0x1f: "Auto, Fired, Return detected",0x20: "No flash function",0x30: "Off, No flash function",0x41: "Fired, Red-eye reduction",0x45: "Fired, Red-eye reduction, Return not detected",0x47: "Fired, Red-eye reduction, Return detected",0x49: "On, Red-eye reduction",0x4d: "On, Red-eye reduction, Return not detected",0x4f: "On, Red-eye reduction, Return detected",0x50: "Off, Red-eye reduction",0x58: "Auto, Did not fire, Red-eye reduction",0x59: "Auto, Fired, Red-eye reduction",0x5d: "Auto, Fired, Red-eye reduction, Return not detected",0x5f: "Auto, Fired, Red-eye reduction, Return detected"} + _metadata.light_source_dictionary = {0: "Unknown", 1: "Daylight", 2: "Fluorescent", 3: "Tungsten (incandescent light)", 4: "Flash", 9: "Fine weather", 10: "Cloudy weather", 11: "Shade", 12: "Daylight fluorescent (D 5700 - 7100K)", 13: "Day white fluorescent (N 4600 - 5400K)", 14: "Cool white fluorescent (W 3900 - 4500K)", 15: "White fluorescent (WW 3200 - 3700K)", 17: "Standard light A", 18: "Standard light B", 19: "Standard light C", 20: "D55", 21: "D65", 22: "D75", 23: "D50", 24: "ISO studio tungsten"} _metadata.metering_list = ["Unknown", "Average", "Center-weighted average", "Spot", "Multi-spot", "Multi-segment", "Partial"] _metadata.exposure_list = ["Not Defined", "Manual", "Program AE", "Aperture-priority AE", "Shutter speed priority AE", "Creative (Slow speed)", "Action (High speed)", "Portrait", "Landscape", "Bulb"] _metadata.orientation_list = ["Horizontal (normal)", "Mirror horizontal", "Rotate 180", "Mirror vertical", "Mirror horizontal and rotate 270 CW", "Rotate 90 CW", "Mirror horizontal and rotate 90 CW", "Rotate 270 CW"] + _metadata.sensing_method_list = ["Not defined", "One-chip color area sensor", "Two-chip color area sensor", "Three-chip color area sensor", "Color sequential area sensor", "Trilinear sensor", "Color sequential linear sensor"] + _metadata.scene_capture_type_list = ["Standard", "Landscape", "Portrait", "Night scene"] + _metadata.subject_distance_range_list = ["Unknown", "Macro", "Close view", "Distant view"] def _thumbnail(self, image, thumb_path, original_path, size, square=False): thumb_path = os.path.join(thumb_path, image_cache(self._path, size, square)) diff --git a/web/js/011-display.js b/web/js/011-display.js index ce20424..acbc9a1 100644 --- a/web/js/011-display.js +++ b/web/js/011-display.js @@ -194,11 +194,15 @@ $(document).ready(function() { if (typeof currentPhoto.size !== "undefined") text += "Resolution" + currentPhoto.size[0] + " x " + currentPhoto.size[1] + ""; if (typeof currentPhoto.aperture !== "undefined") text += "Aperture f/" + getDecimal(currentPhoto.aperture) + ""; if (typeof currentPhoto.focalLength !== "undefined") text += "Focal Length" + getDecimal(currentPhoto.focalLength) + " mm"; + if (typeof currentPhoto.subjectDistanceRange !== "undefined") text += "Subject Distance Range" + currentPhoto.subjectDistanceRange + ""; if (typeof currentPhoto.iso !== "undefined") text += "ISO" + currentPhoto.iso + ""; + if (typeof currentPhoto.sceneCaptureType !== "undefined") text += "Scene Capture Type" + currentPhoto.sceneCaptureType + ""; if (typeof currentPhoto.exposureTime !== "undefined") text += "Exposure Time" + getDecimal(currentPhoto.exposureTime) + " sec"; if (typeof currentPhoto.exposureProgram !== "undefined") text += "Exposure Program" + currentPhoto.exposureProgram + ""; if (typeof currentPhoto.exposureCompensation !== "undefined") text += "Exposure Compensation" + getDecimal(currentPhoto.exposureCompensation) + ""; if (typeof currentPhoto.spectralSensitivity !== "undefined") text += "Spectral Sensitivity" + currentPhoto.spectralSensitivity + ""; + if (typeof currentPhoto.sensingMethod !== "undefined") text += "Sensing Method" + currentPhoto.sensingMethod + ""; + if (typeof currentPhoto.lightSource !== "undefined") text += "Light Source" + currentPhoto.lightSource + ""; if (typeof currentPhoto.flash !== "undefined") text += "Flash" + currentPhoto.flash + ""; if (typeof currentPhoto.orientation !== "undefined") text += "Orientation" + currentPhoto.orientation + ""; text += "";