]> git.datanom.net - lensdb.git/commitdiff
Fix collecting lens data release/0.9 release/0.9.1
authorMichael Rasmussen <mir@datanom.net>
Mon, 28 Oct 2024 01:33:35 +0000 (02:33 +0100)
committerMichael Rasmussen <mir@datanom.net>
Mon, 28 Oct 2024 01:33:35 +0000 (02:33 +0100)
Signed-off-by: Michael Rasmussen <mir@datanom.net>
lib/main.cpp
lib/main.hpp

index e957f1b9193eecf75928c30928532c6c2264c81c..5bf9c43e405956f2ead8cf10fb53e2dfe3a9bb52 100644 (file)
@@ -52,18 +52,33 @@ string ExifScanner::get_maker() {
        
        //g_hash_table_foreach(exif_tags, print_all, NULL);
        const gchar* lensId = (gchar *)g_hash_table_lookup(exif_tags, "LensMake");
-       if (!lensId) {
+       gulong len = g_utf8_strlen(lensId, -1);
+       if (!lensId || g_strcmp0("Unknown (2822)", lensId) == 0 || len < 1) {
                const gchar* s = (gchar *)g_hash_table_lookup(exif_tags, "LensID");
+               if (s && g_strcmp0("Unknown (2822)", s) != 0) {
+                       gchar* pos = g_strstr_len(s, -1, " ");
+                       //cout << pos << endl;
+                       if (pos) {
+                               //cout << "S length: " << strlen(s) << "POS length: " << strlen(pos) << endl;
+                               lensId = g_strndup(s, strlen(s) - strlen(pos));
+                       }
+                       len = g_utf8_strlen(lensId, -1);
+               }
+       }
+
+       if (!lensId || g_strcmp0("Unknown (2822)", lensId) == 0 || len < 1) {
+               const gchar* s = (gchar *)g_hash_table_lookup(exif_tags, "LensModel");
                if (s) {
                        gchar* pos = g_strstr_len(s, -1, " ");
                        //cout << pos << endl;
                        if (pos) {
                                //cout << "S length: " << strlen(s) << "POS length: " << strlen(pos) << endl;
                                lensId = g_strndup(s, strlen(s) - strlen(pos));
+                               len = g_utf8_strlen(lensId, -1);
                        }
                }
        }
-       if (!lensId)
+       if (!lensId || len < 1)
                maker = get_cscring("Unknown");
        else
                maker = get_cscring(lensId);
@@ -75,11 +90,13 @@ string ExifScanner::get_serial_number() {
        string sn;
 
        const gchar* id = (gchar *)g_hash_table_lookup(exif_tags, "LensSerialNumber");
-       if (!id) {
+       gulong len = g_utf8_strlen(id, -1);
+       if (!id || len < 1) {
                id = (gchar *)g_hash_table_lookup(exif_tags, "SerialNumber");
+               len = g_utf8_strlen(id, -1);
        }
        
-       if (!id)
+       if (!id || len < 1)
                sn = get_cscring("Unknown");
        else
                sn = get_cscring(id);
@@ -91,13 +108,17 @@ string ExifScanner::get_lens() {
        string lens;
 
        const gchar* lensId = (gchar *)g_hash_table_lookup(exif_tags, "LensID");
-       if (!lensId) {
+       gulong len = g_utf8_strlen(lensId, -1);
+       if (!lensId || g_strcmp0("Unknown (2822)", lensId) == 0 || len < 1) {
                lensId = (gchar *)g_hash_table_lookup(exif_tags, "LensModel");
-               if (!lensId)
+               len = g_utf8_strlen(lensId, -1);
+               if (!lensId || g_strcmp0("Unknown (2822)", lensId) == 0 || len < 1) {
                        lensId = (gchar *)g_hash_table_lookup(exif_tags, "LensSpec");
+                       len = g_utf8_strlen(lensId, -1);
+               }
        }
        
-       if (!lensId)
+       if (!lensId || g_strcmp0("Unknown (2822)", lensId) == 0 || len < 1)
                lens = get_cscring("Unknown");
        else
                lens = get_cscring(lensId);
index b2cb449944c690ae0cc427905f2832e8cbcbc0e6..4112540a125b0c7a926b5a7698df83ed5e2ad7a4 100644 (file)
@@ -28,6 +28,7 @@
 #include <iostream>
 #include <string>
 #include <glib.h>
+#include <gmodule.h>
 #include "ExifTool.h"
 
 class ExifScanner {
This page took 0.307186 seconds and 5 git commands to generate.