From e3e8e3297d0afc9c291e0dd964ad66b11fa53e46 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Sat, 7 May 2011 03:42:44 -0400 Subject: [PATCH] Meta data consolidation. --- scanner/PhotoAlbum.py | 21 ++++++++++++++------- web/css/000-controls.css | 4 +++- web/js/010-control.js | 21 ++++++++++++--------- 3 files changed, 29 insertions(+), 17 deletions(-) diff --git a/scanner/PhotoAlbum.py b/scanner/PhotoAlbum.py index 367c56c..7147fc1 100644 --- a/scanner/PhotoAlbum.py +++ b/scanner/PhotoAlbum.py @@ -151,15 +151,15 @@ class Photo(object): self._orientation = exif["Orientation"]; if self._orientation in range(5, 9): self._attributes["size"] = (self._attributes["size"][1], self._attributes["size"][0]) - self._attributes["orientation"] = ["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"][self._orientation - 1] + self._attributes["orientation"] = self._metadata.orientation_list[self._orientation - 1] if "Make" in exif: self._attributes["make"] = exif["Make"] if "Model" in exif: self._attributes["model"] = exif["Model"] if "ApertureValue" in exif: self._attributes["aperture"] = exif["ApertureValue"] - if "FNumber" in exif: - self._attributes["fStop"] = exif["FNumber"] + elif "FNumber" in exif: + self._attributes["aperture"] = exif["FNumber"] if "FocalLength" in exif: self._attributes["focalLength"] = exif["FocalLength"] if "ISOSpeedRatings" in exif: @@ -173,16 +173,19 @@ class Photo(object): if "MeteringMode" in exif: self._attributes["meteringMode"] = exif["MeteringMode"] if "Flash" in exif: - self._attributes["flash"] = exif["Flash"] != 0 + try: + self._attributes["flash"] = self._metadata.flash_dictionary[exif["Flash"]] + except: + pass if "ExposureProgram" in exif: - self._attributes["exposureProgram"] = ["Not Defined", "Manual", "Program AE", "Aperture-priority AE", "Shutter speed priority AE", "Creative (Slow speed)", "Action (High speed)", "Portrait", "Landscape", "Bulb"][exif["ExposureProgram"]] + self._attributes["exposureProgram"] = self._metadata.exposure_list[exif["ExposureProgram"]] if "SpectralSensitivity" in exif: self._attributes["spectralSensitivity"] = exif["SpectralSensitivity"] if "MeteringMode" in exif: if exif["MeteringMode"] == 255: self._attributes["meteringMode"] = "Other" else: - self._attributes["meteringMode"] = ["Unknown", "Average", "Center-weighted average", "Spot", "Multi-spot", "Multi-segment", "Partial"][exif["MeteringMode"]] + self._attributes["meteringMode"] = self._metadata.metering_list[exif["MeteringMode"]] if "ExposureCompensation" in exif: self._attributes["exposureCompensation"] = exif["ExposureCompensation"] if "ExposureBiasValue" in exif: @@ -191,7 +194,11 @@ class Photo(object): self._attributes["dateTimeOriginal"] = exif["DateTimeOriginal"] if "DateTime" in exif: 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.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"] def _thumbnail(self, image, thumb_path, size, square=False): thumb_path = os.path.join(thumb_path, image_cache(self._path, size, square)) diff --git a/web/css/000-controls.css b/web/css/000-controls.css index 694afd4..8148c2b 100644 --- a/web/css/000-controls.css +++ b/web/css/000-controls.css @@ -105,7 +105,7 @@ a:hover { } #metadata { background-color: #000000; - width: 240px; + width: 270px; font-size: 12px; line-height: 12px; padding-top: 3px; @@ -124,8 +124,10 @@ a:hover { opacity: 0.5; -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=50)"; filter: alpha(opacity=50); + overflow: auto; } #metadata table { + margin: auto auto; text-align: left; } #metadata tr { diff --git a/web/js/010-control.js b/web/js/010-control.js index 4803dc5..add9760 100644 --- a/web/js/010-control.js +++ b/web/js/010-control.js @@ -119,6 +119,11 @@ $(document).ready(function() { $("#subalbums").show(); $("#photo-view").hide(); } + function getDecimal(fraction) { + if (fraction[0] < fraction[1]) + return fraction[0] + "/" + fraction[1]; + return (fraction[0] / fraction[1]).toString(); + } function showPhoto() { currentPhoto(); if (current_photo == null) { @@ -156,16 +161,14 @@ $(document).ready(function() { if (current_photo.model != undefined) text += "Camera Model" + current_photo.model + ""; if (current_photo.date != undefined) text += "Time Taken" + current_photo.date + ""; if (current_photo.size != undefined) text += "Resolution" + current_photo.size[0] + " x " + current_photo.size[1] + ""; - if (current_photo.aperture != undefined) text += "Aperture" + current_photo.aperture + ""; - if (current_photo.fStop != undefined) text += "F-Stop" + current_photo.fStop + ""; - if (current_photo.focalLength != undefined) text += "Focal Length" + current_photo.focalLength + ""; + if (current_photo.aperture != undefined) text += "Aperture f/" + getDecimal(current_photo.aperture) + ""; + if (current_photo.focalLength != undefined) text += "Focal Length" + getDecimal(current_photo.focalLength) + " mm"; if (current_photo.iso != undefined) text += "ISO" + current_photo.iso + ""; - if (current_photo.exposureTime != undefined) text += "Exposure Time" + current_photo.exposureTime + ""; + if (current_photo.exposureTime != undefined) text += "Exposure Time" + getDecimal(current_photo.exposureTime) + " sec"; if (current_photo.exposureProgram != undefined) text += "Exposure Program" + current_photo.exposureProgram + ""; - if (current_photo.exposureCompensation != undefined) text += "Exposure Compensation" + current_photo.exposureCompensation + ""; - if (current_photo.exposureBiasValue != undefined) text += "Exposure Bias" + current_photo.exposureBiasValue + ""; - if (current_photo.spectralSensitivity != undefined) text += "Spectra lSensitivity" + current_photo.spectralSensitivity + ""; - if (current_photo.flash != undefined) text += "Flash" + (current_photo.flash ? "Yes" : "No") + ""; + if (current_photo.exposureCompensation != undefined) text += "Exposure Compensation" + getDecimal(current_photo.exposureCompensation) + ""; + if (current_photo.spectralSensitivity != undefined) text += "Spectral Sensitivity" + current_photo.spectralSensitivity + ""; + if (current_photo.flash != undefined) text += "Flash" + current_photo.flash + ""; if (current_photo.orientation != undefined) text += "Orientation" + current_photo.orientation + ""; text += ""; $("#metadata").html(text); @@ -278,7 +281,7 @@ $(document).ready(function() { .css("padding-top", 0) .css("padding-bottom", 0) .show() - .animate({ height: 16 * 12, paddingTop: 3, paddingBottom: 3 }, "slow", function() { + .animate({ height: 16 * 11, paddingTop: 3, paddingBottom: 3 }, "slow", function() { $("#metadata-link").text($("#metadata-link").text().replace("show", "hide")); }); else