News:

2023-03-15 Major improvements to the new Geolocation feature

Main Menu

reconstruct datetimeoriginal using GPS information

Started by kngharv, June 10, 2021, 04:22:21 AM

Previous topic - Next topic

kngharv

Dear all:

Some of my photo's
Quotedategimeoriginal
value wasn't correct because I forgot to change my camera's timezone when I travel.

For geotagged photos, the UTC time and Long/Lat are recorded.  In theory, I could reconstruct a time-zone appropriate datetimeoriginal  using geotagged data.

Is there a convenient way to write a shell script along with exiftool to accomplish such, leveraging linux' built-in timezone database? 

Thanks in advance

Harv

Phil Harvey

Hi Harv,

The normal way to do this is to shift the affected date/time tags (see here).

Adjusting according to the system time zone would be trickier, and I don't have time to think about this much right now.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Hubert

I've had some time and I've done a bit of a thought experiment, and I don't think there's a straightforward solution.

If you try it through your built-in timezone database, I suspect you'll be re-inventing the wheel. There are many web services that will calculate time zone from latitude and longitude - I signed up to https://timezonedb.com, which requires free registration and then offers one call free call per second.

First, you would probably need to convert the EXIF Degrees-Minutes-Seconds values to decimal degrees. That's Degrees + (Minutes/60) + (Seconds/3600). I don't know if that's possible within ExifTool: you might need a specialised config file if not a separate script.

Passing those values to the web service (via CURL for example) can return the time zone name of your photos.

For example this

curl "http://api.timezonedb.com/v2.1/get-time-zone?key=************&format=xml&by=position&lat=52.023333333333&lng=1.361388888889&fields=zoneName"

returns this

<?xml version=\"1.0\" encoding=\"utf-8\"?>
<result><status>OK</status><message/><zoneName>Europe/London</zoneName></result>


Out of which you can parse the name of the time zone: Europe/London

This, basically, is as far as I got.

Your next challenge would be to determine if that time zone was applying Daylight Savings on the exact date and time you took your photos. The built-in database (if it's the same as the one at https://www.iana.org/time-zones) has that information, but extracting it programatically is non-trivial and (currently) beyond my skills.

If you can break that barrier, you would be able to calculate the difference between the time zone of your pictures (with or without DST), and UTC.

You could then use ExifTool to shift -datetimeoriginal by that difference.

Once you have all that running, it would no doubt be efficient. Writing the code is another matter...

StarGeek

Quote from: Hubert on June 11, 2021, 06:17:10 PM
First, you would probably need to convert the EXIF Degrees-Minutes-Seconds values to decimal degrees. That's Degrees + (Minutes/60) + (Seconds/3600). I don't know if that's possible within ExifTool: you might need a specialised config file if not a separate script.

Use the -c (-coordFormat) option to format it how you want or -n (--printConv) option which outputs just decimal.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).