X-Git-Url: http://git.datanom.net/lensdb.git/blobdiff_plain/1689100fc9cd30b34628a2ab6fac95ee7f0977db..refs/heads/release/0.9:/lib/main.cpp?ds=sidebyside diff --git a/lib/main.cpp b/lib/main.cpp index e957f1b..5bf9c43 100644 --- a/lib/main.cpp +++ b/lib/main.cpp @@ -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);