From 06949e05666e83befad1b17ffab01876fa179642 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Thu, 6 Sep 2012 21:14:26 +0100 Subject: [PATCH] [Geotagging] Improve detection of image files having GPS information. Encountered some images which have just the EXIF_TAG_GPS_VERSION_ID but nothing else. So to confirm GPS info, check existance of more EXIF GPS tags (Latitude and Longitude) Thus when such images are requested for geotagging they won't be erroneously skipped over. --- src/geotag_exif.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/geotag_exif.c b/src/geotag_exif.c index de446a15..2dcb0fae 100644 --- a/src/geotag_exif.c +++ b/src/geotag_exif.c @@ -307,6 +307,7 @@ VikWaypoint* a_geotag_waypoint_positioned ( const gchar *filename, VikCoord coor gchar* a_geotag_get_exif_date_from_file ( const gchar *filename, gboolean *has_GPS_info ) { gchar* datetime = NULL; + *has_GPS_info = FALSE; ExifData *ed = exif_data_new_from_file ( filename ); @@ -324,13 +325,22 @@ gchar* a_geotag_get_exif_date_from_file ( const gchar *filename, gboolean *has_G } // Check GPS Info - *has_GPS_info = FALSE; - + ee = exif_content_get_entry (ed->ifd[EXIF_IFD_GPS], EXIF_TAG_GPS_VERSION_ID); // Confirm this has a GPS Id - normally "2.0.0.0" or "2.2.0.0" if ( ee && ee->components == 4 ) *has_GPS_info = TRUE; + // Check other basic GPS fields exist too + // I have encountered some images which have just the EXIF_TAG_GPS_VERSION_ID but nothing else + // So to confirm check more EXIF GPS TAGS: + ee = exif_content_get_entry (ed->ifd[EXIF_IFD_GPS], EXIF_TAG_GPS_LATITUDE); + if ( !ee ) + *has_GPS_info = FALSE; + ee = exif_content_get_entry (ed->ifd[EXIF_IFD_GPS], EXIF_TAG_GPS_LONGITUDE); + if ( !ee ) + *has_GPS_info = FALSE; + exif_data_free ( ed ); return datetime; -- 2.39.5