Updating gpsdatetime using datetimeoriginal from multiple timezones

Started by yakiimo, December 26, 2016, 07:20:14 AM

Previous topic - Next topic

yakiimo

I'm trying to geotag my SLR camera's pics using geotag from my smartphone's pics (using -p gpx_template.fmt) and it works great except when using geotag source from iPhone5's pics, because pics are missing gpsdatetime which is used in gpx_template.fmt  :-\ :

--> exiftool -gpstimestamp -datetimeoriginal -gpsdatetime iphone6/IMG_4525.JPG
GPS Time Stamp                  : 12:31:05.75
Date/Time Original              : 2015:07:22 14:31:10
GPS Date/Time                   : 2015:07:22 12:31:05.75Z
--> exiftool -gpstimestamp -datetimeoriginal -gpsdatetime iphone5/IMG_3867.JPG
GPS Time Stamp                  : 23:02:02.92
Date/Time Original              : 2013:06:01 08:02:04


One complication is that I have pics from multiple timezones and I can't rely on file's fs timezone. Most of them are in GMT+9 so I tried this:

-> exiftool -P -r -if 'not $gpsdatetime' -if '${datetimeoriginal;s/.* ([0-9]{2}):.*/$1/} eq ${gpstimestamp;s/:.*//}+9' '-gpsdatestamp<${datetimeoriginal}-09:00' ~/Documents/iphone5_copy
    1 directories scanned
  855 files failed condition
1561 image files updated


But this only works from 1 timezone and not even for pics that were take before 9am, so I tried being creative with a condition like this, but it doesn't seems to resolve.

-if '${${datetimeoriginal}-09:00};s/.* ([0-9]{2}):.*/$1/} eq ${gpstimestamp;s/:.*//}'


Anyone knows if there's a syntax to make this above 'if' statement works?

If there's a better way to solve this problem I'd be happy to hear suggestions.

I hope I stated this issue in understand way  :)

Thanks,

Hayo Baan

If I understand correctly you want to set the gpsdatetime to match the time of shooting (i.e., the datatimeoriginal with the correct timezone) – but only for those files that don't yet have the gpsdatetime set from the camera.

I see what you are trying to do with the second command (pretty smart by the way ;)): there you are using the gpstimestamp (which is available) to determine if they are 9 hours apart (you should have used == not eq here, also you are setting gpsdatestamp where you wanted to set gpsdatetime?).

Anyway, I think this should overcome the issue when times are < 09 (simply take the hour+9 modulo 24):
exiftool -P -r -if 'not $gpsdatetime && (${datetimeoriginal;s/.* ([0-9]{2}):.*/$1/} == (${gpstimestamp;s/:.*//}+9) % 24)' '-gpsdatetime<${datetimeoriginal}-09:00' ~/Documents/iphone5_copy
Perform similar statements for the other time zones.
Hayo Baan – Photography
Web: www.hayobaan.nl

yakiimo

Thanks Hayo! Yes modulo 24 works (that's pretty smart ;))! yes right 'eq' is for string comparison '==' is better here.

Actually I'm setting gpsdatestamp on purpose which triggers gpsdatetime auto-update. If I explicitly set gpsdatetime, result isn't working when I export using -p gpx_template.fmt :


--> cp -a Documents/temp/IMG_3867.JPG.JP.8am.orig Documents/temp/IMG_3867.JPG.JP.8am
--> exiftool -gpstimestamp -datetimeoriginal -gpsdatetime Documents/temp/IMG_3867.JPG.JP.8am
GPS Time Stamp                  : 23:02:02.92
Date/Time Original              : 2013:06:01 08:02:04
--> exiftool -P -if 'not $gpsdatetime'  '-gpstimestamp<gpstimestamp' '-gpsdatetime<${datetimeoriginal}-09:00' Documents/temp/IMG_3867.JPG.JP.8am
    1 image files updated
--> exiftool -gpstimestamp -datetimeoriginal -gpsdatetime Documents/temp/IMG_3867.JPG.JP.8am
GPS Time Stamp                  : 23:02:02.92
Date/Time Original              : 2013:06:01 08:02:04
GPS Date/Time                   : 2013:06:01 08:02:04-09:00
--> cp -a Documents/temp/IMG_3867.JPG.JP.8am.orig Documents/temp/IMG_3867.JPG.JP.8am
--> exiftool -P -if 'not $gpsdatetime'  '-gpstimestamp<gpstimestamp' '-gpsdatestamp<${datetimeoriginal}-09:00' Documents/temp/IMG_3867.JPG.JP.8am
    1 image files updated
--> exiftool -gpstimestamp -datetimeoriginal -gpsdatetime Documents/temp/IMG_3867.JPG.JP.8am
GPS Time Stamp                  : 23:02:02.92
Date/Time Original              : 2013:06:01 08:02:04
GPS Date/Time                   : 2013:06:01 23:02:02.92Z

yakiimo

Actually correction, only gpsdatetime must be updated otherwise date isn't calculate properly (above post 06/01 vs this post 05/31), and it's +9 to get expected results, that's confusing.


--> cp -a Documents/temp/IMG_3867.JPG.JP.8am.orig Documents/temp/IMG_3867.JPG.JP.8am
--> exiftool -gpstimestamp -datetimeoriginal -gpsdatetime Documents/temp/IMG_3867.JPG.JP.8am
GPS Time Stamp                  : 23:02:02.92
Date/Time Original              : 2013:06:01 08:02:04
--> exiftool -P '-gpsdatetime<${datetimeoriginal}+09:00'  Documents/temp/IMG_3867.JPG.JP.8am
    1 image files updated
--> exiftool -gpstimestamp -datetimeoriginal -gpsdatetime Documents/temp/IMG_3867.JPG.JP.8am
GPS Time Stamp                  : 23:02:02.92
Date/Time Original              : 2013:06:01 08:02:04
GPS Date/Time                   : 2013:06:01 08:02:04+09:00
--> cp -a Documents/temp/IMG_3867.JPG.JP.8am.orig Documents/temp/IMG_3867.JPG.JP.8am
--> exiftool -P '-gpsdatestamp<${datetimeoriginal}+09:00'  Documents/temp/IMG_3867.JPG.JP.8am
    1 image files updated
--> exiftool -gpstimestamp -datetimeoriginal -gpsdatetime Documents/temp/IMG_3867.JPG.JP.8am
GPS Time Stamp                  : 23:02:02.92
Date/Time Original              : 2013:06:01 08:02:04
GPS Date/Time                   : 2013:05:31 23:02:02.92Z

Hayo Baan

Hmm, strange behaviour which is probably explainable, but I need to look into this some more. I didn't yet have a file with GPS info handy so I wasn't able to see what happens with the date stamp vs datetime tag. I need to look into this some more and see if I can find a file that doesn't have the gpsdatetime like yours and see what I can find that works even better/easier to get everything correct. Perhaps you can mail me a sample as well?
Hayo Baan – Photography
Web: www.hayobaan.nl

Hayo Baan

Quote from: Hayo Baan on December 28, 2016, 02:08:35 AM
Hmm, strange behaviour which is probably explainable, but I need to look into this some more. I didn't yet have a file with GPS info handy so I wasn't able to see what happens with the date stamp vs datetime tag. I need to look into this some more and see if I can find a file that doesn't have the gpsdatetime like yours and see what I can find that works even better/easier to get everything correct. Perhaps you can mail me a sample as well?

I got an image of an iPhone4s and while that file has both a GPSDateStamp as well as a GPSTimeStamp I can mimic your problem by removing the tag manually. However, I now also understand the behaviour you are seeing: The GPSDateTime you are referring to is NOT a normal tag, but derived from GPSDateStamp in combination with GPSTimeStamp. The confusing thing is that when you wrote the tag with '-gpsdatetime<${datetimeoriginal}+09:00', exiftool created an XMP tag, not the GPS tag you really needed. That's why you do need to write GPSDateStamp (and only that).

I also now understand why you need to reverse the sign of the timezone when writing the gpsdatestamp; datetimeoriginal is local time and to convert that back to UTC, the timezone needs to be applied in reverse :)
Hayo Baan – Photography
Web: www.hayobaan.nl