Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(654)

Unified Diff: ui/file_manager/file_manager/foreground/elements/files_metadata_box.js

Issue 2564553002: Quick View: Add device setting metadata. (Closed)
Patch Set: s/Shooting Info/Device Settgins/. Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/file_manager/file_manager/foreground/elements/files_metadata_box.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/file_manager/file_manager/foreground/elements/files_metadata_box.js
diff --git a/ui/file_manager/file_manager/foreground/elements/files_metadata_box.js b/ui/file_manager/file_manager/foreground/elements/files_metadata_box.js
index 834def10ccd5080a4d92b4397dc83f84cf0da608..e045432baf8dfab1686e8594d7fc9c7fbe95504a 100644
--- a/ui/file_manager/file_manager/foreground/elements/files_metadata_box.js
+++ b/ui/file_manager/file_manager/foreground/elements/files_metadata_box.js
@@ -166,6 +166,18 @@ var FilesMetadataBox = Polymer({
},
/**
+ * @param {Array<String>} r array of two strings representing the numerator
+ * and the denominator.
+ * @return {number}
+ * @private
+ */
+ parseRational_: function(r) {
+ var num = parseInt(r[0], 10);
+ var den = parseInt(r[1], 10);
+ return num / den;
+ },
+
+ /**
* Returns geolocation as a string in the form of 'latitude, longitude',
* where the values have 3 decimal precision. Negative latitude indicates
* south latitude and negative longitude indicates west longitude.
@@ -179,22 +191,54 @@ var FilesMetadataBox = Polymer({
if (!gps || !gps[1] || !gps[2] || !gps[3] || !gps[4])
return '';
- var parseRationale = function(r) {
- var num = parseInt(r[0], 10);
- var den = parseInt(r[1], 10);
- return num / den;
- };
-
- var computeCorrdinate = function(value) {
- return parseRationale(value[0]) + parseRationale(value[1]) / 60 +
- parseRationale(value[2]) / 3600;
- };
+ var computeCoordinate = function(value) {
+ return this.parseRational_(value[0]) +
+ this.parseRational_(value[1]) / 60 +
+ this.parseRational_(value[2]) / 3600;
+ }.bind(this);
var latitude =
- computeCorrdinate(gps[2].value) * (gps[1].value === 'N\0' ? 1 : -1);
+ computeCoordinate(gps[2].value) * (gps[1].value === 'N\0' ? 1 : -1);
var longitude =
- computeCorrdinate(gps[4].value) * (gps[3].value === 'E\0' ? 1 : -1);
+ computeCoordinate(gps[4].value) * (gps[3].value === 'E\0' ? 1 : -1);
return Number(latitude).toFixed(3) + ', ' + Number(longitude).toFixed(3);
},
+
+ /**
+ * Returns device settings as a string in the form of
+ * 'FNumber exposureTime focalLength isoSpeedRating'.
+ * Example: 'f/2 1/120 4.67mm ISO108'.
+ * @param {?Object} ifd
+ * @return {string}
+ *
+ * @private
+ */
+ deviceSettings_: function(ifd) {
+ var exif = ifd && ifd.exif;
+ if (!exif)
+ return '';
+
+ var f = exif[33437] ? this.parseRational_(exif[33437].value) : 0;
+ var fNumber = '';
+ if (f) {
+ fNumber = 'f/' + (Number.isInteger(f) ? f : Number(f).toFixed(1));
+ }
+ var exposureTime =
+ exif[33434] ? exif[33434].value[0] + '/' + exif[33434].value[1] : '';
+ var focalLength = exif[37386] ?
+ Number(this.parseRational_(exif[37386].value)).toFixed(2) + 'mm' :
+ '';
+ var iso = exif[34855] ? 'ISO' + exif[34855].value : '';
+
+ var values = [fNumber, exposureTime, focalLength, iso];
+
+ var result = '';
+ for (var i = 0; i < values.length; i++) {
+ if (values[i]) {
+ result += (result ? ' ' : '') + values[i];
+ }
+ }
+ return result;
+ },
});
« no previous file with comments | « ui/file_manager/file_manager/foreground/elements/files_metadata_box.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698