Meta data consolidation.

master
Jason A. Donenfeld 2011-05-07 03:42:44 -04:00
parent e87fe0a96c
commit e3e8e3297d
3 changed files with 29 additions and 17 deletions

View File

@ -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))

View File

@ -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 {

View File

@ -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 += "<tr><td>Camera Model</td><td>" + current_photo.model + "</td></tr>";
if (current_photo.date != undefined) text += "<tr><td>Time Taken</td><td>" + current_photo.date + "</td></tr>";
if (current_photo.size != undefined) text += "<tr><td>Resolution</td><td>" + current_photo.size[0] + " x " + current_photo.size[1] + "</td></tr>";
if (current_photo.aperture != undefined) text += "<tr><td>Aperture</td><td>" + current_photo.aperture + "</td></tr>";
if (current_photo.fStop != undefined) text += "<tr><td>F-Stop</td><td>" + current_photo.fStop + "</td></tr>";
if (current_photo.focalLength != undefined) text += "<tr><td>Focal Length</td><td>" + current_photo.focalLength + "</td></tr>";
if (current_photo.aperture != undefined) text += "<tr><td>Aperture</td><td> f/" + getDecimal(current_photo.aperture) + "</td></tr>";
if (current_photo.focalLength != undefined) text += "<tr><td>Focal Length</td><td>" + getDecimal(current_photo.focalLength) + " mm</td></tr>";
if (current_photo.iso != undefined) text += "<tr><td>ISO</td><td>" + current_photo.iso + "</td></tr>";
if (current_photo.exposureTime != undefined) text += "<tr><td>Exposure Time</td><td>" + current_photo.exposureTime + "</td></tr>";
if (current_photo.exposureTime != undefined) text += "<tr><td>Exposure Time</td><td>" + getDecimal(current_photo.exposureTime) + " sec</td></tr>";
if (current_photo.exposureProgram != undefined) text += "<tr><td>Exposure Program</td><td>" + current_photo.exposureProgram + "</td></tr>";
if (current_photo.exposureCompensation != undefined) text += "<tr><td>Exposure Compensation</td><td>" + current_photo.exposureCompensation + "</td></tr>";
if (current_photo.exposureBiasValue != undefined) text += "<tr><td>Exposure Bias</td><td>" + current_photo.exposureBiasValue + "</td></tr>";
if (current_photo.spectralSensitivity != undefined) text += "<tr><td>Spectra lSensitivity</td><td>" + current_photo.spectralSensitivity + "</td></tr>";
if (current_photo.flash != undefined) text += "<tr><td>Flash</td><td>" + (current_photo.flash ? "Yes" : "No") + "</td></tr>";
if (current_photo.exposureCompensation != undefined) text += "<tr><td>Exposure Compensation</td><td>" + getDecimal(current_photo.exposureCompensation) + "</td></tr>";
if (current_photo.spectralSensitivity != undefined) text += "<tr><td>Spectral Sensitivity</td><td>" + current_photo.spectralSensitivity + "</td></tr>";
if (current_photo.flash != undefined) text += "<tr><td>Flash</td><td>" + current_photo.flash + "</td></tr>";
if (current_photo.orientation != undefined) text += "<tr><td>Orientation</td><td>" + current_photo.orientation + "</td></tr>";
text += "</table>";
$("#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