[gexiv2] metadata: Fallback to ApertureValue if FNumber is absent or invalid



commit 80174b329c38172d5d39c84438095bccb95becaf
Author: Debarshi Ray <debarshir gnome org>
Date:   Fri Jan 5 12:24:52 2018 +0100

    metadata: Fallback to ApertureValue if FNumber is absent or invalid
    
    https://bugzilla.gnome.org/show_bug.cgi?id=792239

 gexiv2/gexiv2-metadata.cpp |   14 +++++++++++++-
 1 files changed, 13 insertions(+), 1 deletions(-)
---
diff --git a/gexiv2/gexiv2-metadata.cpp b/gexiv2/gexiv2-metadata.cpp
index 2b7424f..3a78084 100644
--- a/gexiv2/gexiv2-metadata.cpp
+++ b/gexiv2/gexiv2-metadata.cpp
@@ -19,6 +19,7 @@
 #include "gexiv2-log.h"
 #include "gexiv2-log-private.h"
 #include <string>
+#include <cmath>
 #include <glib-object.h>
 #include <gio/gio.h>
 #include <exiv2/image.hpp>
@@ -784,7 +785,18 @@ gboolean gexiv2_metadata_get_exposure_time (GExiv2Metadata *self, gint *nom, gin
 }
 
 gdouble gexiv2_metadata_get_fnumber (GExiv2Metadata *self) {
-    return gexiv2_metadata_get_exif_tag_rational_as_double(self, "Exif.Photo.FNumber", -1.0);
+    gdouble fnumber = gexiv2_metadata_get_exif_tag_rational_as_double(self, "Exif.Photo.FNumber", -1.0);
+    if (fnumber == -1.0) {
+        gdouble aperture_value = gexiv2_metadata_get_exif_tag_rational_as_double(self,
+                                                                                 "Exif.Photo.ApertureValue",
+                                                                                 -1.0);
+        if (aperture_value == -1.0)
+          return fnumber;
+
+        fnumber = pow (2.0, aperture_value / 2.0);
+    }
+
+    return fnumber;
 }
 
 gdouble gexiv2_metadata_get_focal_length (GExiv2Metadata *self) {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]