News:

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

Main Menu

Inverse geotagging images from iPhone

Started by TrackGen, January 02, 2023, 05:51:25 AM

Previous topic - Next topic

TrackGen

Hi,
I'm trying to get ExifTool to work for me on a mac - but seem to do something wrong...
I have a folder of (many) images shot on an iPhone (HEIC+DNG format), all geotagged, and I need the location data extracted to create a GPX track on map. All a pretty straight forward job for ExifTool, as far as I understand :) But my skills with Terminal might be less sharp...

I'm using the "Inverse Geotagging" section of the website for reference (link: https://exiftool.org/geotag.html#Inverse). From there I get the command:
exiftool -r -if '$gpsdatetime' -fileOrder gpsdatetime -p gpx.fmt /Users/Me/Desktop/GPX > out.gpx

Now that DOES return a GPX file, but with no usefull information. When I open it in a txt reader, this is what the file contains:
gpx.fmt
gpx.fmt
gpx.fmt
gpx.fmt
gpx.fmt
gpx.fmt
(it's a folder of six test files, so there is a data entry for each file, meaning ExifTool must be reading the file - but not extracting the right information)

I've double-checked the files and they DO contain all metadata (including GPS information). So it must be me writing something wrong... I've tried the following variations of the command, but the all return the same file as the example above:
exiftool -r -if '$gpsdatetime' -fileOrder gpsdatetime -p gpx.fmt /Users/Me/Desktop/GPX > out.gpx
exiftool -fileOrder gpsdatetime -p gpx.fmt /Users/Me/Desktop/GPX > out.gpx
exiftool -p gpx.fmt  /Users/Me/Desktop/GPX > out.gpx

Can anybody help me get a useful list of coordinates? I would be SO thankful!!
Best
/K

StarGeek

Quote from: TrackGen on January 02, 2023, 05:51:25 AMNow that DOES return a GPX file, but with no usefull information. When I open it in a txt reader, this is what the file contains:
gpx.fmt
gpx.fmt
gpx.fmt
gpx.fmt
gpx.fmt
gpx.fmt

This is the output you get when you either don't have the gpx.fmt file or have the wrong path to the format file.

You can either copy/paste the gpx.fmt file from what is listed at here or you can download the file from GitHub.

Once you have created the gpx.fmt file, either put it in the current directory or give the full path to the file.
* 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).

TrackGen

#2
Thanks StarGeek - I see what you mean. And I thought I had it figured, but apparently not...
I think I just need to get the logics straight in my head :)
So I've downloaded the gpx.fmt file and placed it in the same folder as the six test images. The path to images and gpx.fmt is: /Users/Me/Desktop/GPX

So I try the most simple version of the script I can find in the documentation:
exiftool -p gpx.fmt /Users/Me/Desktop/GPX > out.gpx
That still return the same out.gpx as before containing six lines of "gpx.fmt" text.
I try to add the path to the gpx.fmt file and run the script like this:
exiftool -p /Users/Me/Desktop/GPX/gpx.fmt /Users/Me/Desktop/GPX > out.gpx
That returns the same out.gpx file with six lines, but now containing the file path, like this:
/Users/Me/Desktop/GPX/gpx.fmt
/Users/Me/Desktop/GPX/gpx.fmt
/Users/Me/Desktop/GPX/gpx.fmt
/Users/Me/Desktop/GPX/gpx.fmt
/Users/Me/Desktop/GPX/gpx.fmt
/Users/Me/Desktop/GPX/gpx.fmt
/Users/Me/Desktop/GPX/gpx.fmt

I'm getting the idea I'm running this wrong... But I'm not sure where or what. Guessing I'm a true newbie here :) Thanks again!
/K

StarGeek

For whatever reason, exiftool isn't finding the format file.  If the file had any text in it then that would be what shows up.  If it was an empty file, 0 bytes, then exiftool would list normal output.

Since the -p (-printFormat) option is listing the text that follows it, that means that it can't find a file with that name.

Make sure there aren't any permission problems and if there are any spaces in file path, make sure and put quotes around it.
* 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).

Phil Harvey

Try this command:

exiftool -p DRAG_AND_DROP_GPX.FMT_ONTO_THE_TERMINAL_WINDOW_HERE
DRAG_AND_DROP_THE_IMAGE_FOLDER_ONTO_THE_TERMINAL_WINDOW_HERE > out.gpx


(make sure there are spaces before and after the files/folders that you dropped).

- 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 ($).

TrackGen

Quote from: StarGeek on January 03, 2023, 12:14:32 PMMake sure there aren't any permission problems and if there are any spaces in file path, make sure and put quotes around it.
Thanks StarGeek - I've checked all files again, and all permissions are open, so there should be no problem there. Also no spaces in file path either.

Quote from: Phil Harvey on January 03, 2023, 01:58:35 PMexiftool -p DRAG_AND_DROP_GPX.FMT_ONTO_THE_TERMINAL_WINDOW_HERE
DRAG_AND_DROP_THE_IMAGE_FOLDER_ONTO_THE_TERMINAL_WINDOW_HERE > out.gpx


(make sure there are spaces before and after the files/folders that you dropped).
Thanks Phil! It works nicely to drag/drop the files and folders to be sure to get the accurate path (didn't know that trick) ;-) Unfortunately the result is still the same list in the out.gpx file:
/Users/Me/Desktop/GPX/gpx.fmt
/Users/Me/Desktop/GPX/gpx.fmt
/Users/Me/Desktop/GPX/gpx.fmt
/Users/Me/Desktop/GPX/gpx.fmt
/Users/Me/Desktop/GPX/gpx.fmt
/Users/Me/Desktop/GPX/gpx.fmt
/Users/Me/Desktop/GPX/gpx.fmt

Just to be sure it was not a problem with the HEIC file format, I dropped a JPG into the folder as well - but it just gives me another line of "/Users/Me/Desktop/GPX/gpx.fmt"

My silly-feeling-meter is rising fast here :) I've done my good share of scripting before, but somehow can't get this one to play nice with me.
Is there anything else I could try?

Thanks so much!

Phil Harvey

Wow, that is odd.  What version of ExifTool are you using?  The current version is 12.53.  You may see this problem if you are using a very old version.

Another thing to try would be to run ExifTool on the gpx.fmt file to see if it can be opened:

exiftool DRAG_AND_DROP_GPX.FMT_ONTO_THE_TERMINAL_WINDOW_HERE

you should get this (among other things):

File Type                       : TXT
File Type Extension             : txt
MIME Type                       : text/plain
MIME Encoding                   : us-ascii
Newlines                        : Unix LF
Line Count                      : 39
Word Count                      : 191
File Extension                  : fmt
File Type Description           : Text file

- 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 ($).

TrackGen

AHA! Phil, your last message gave me a clue to what was happening. The text inside the gpx.fmt file is mentioning the file type as a TXT file. Mac is known to be a bit weird with file extensions - and I probably should have guessed that this could make things act up a bit :) Anyway, if I manually add a .txt ending so the actual files becomes "gpx.fmt.txt" things work as intended!
Not sure about the logics, but at least it works now :)

Thanks again Phil and StarGeek for your great inputs!

/K

Phil Harvey

I'm glad you got it working but I don't understand why.

You added a ".txt" to the file name?  Or just in the command?  Or both?

The extension might matter to the Mac UI, but it isn't an issue for ExifTool as long as you type the correct file name in the command.  I ran some tests here on my Mac and even if the file extension is hidden in the Mac UI, dragging and dropping the file on Terminal gives the correct file name for the command line.

- 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 ($).

TrackGen

Quote from: Phil Harvey on January 04, 2023, 07:31:38 AMI'm glad you got it working but I don't understand why.

You added a ".txt" to the file name?  Or just in the command?  Or both?

The extension might matter to the Mac UI, but it isn't an issue for ExifTool as long as you type the correct file name in the command.  I ran some tests here on my Mac and even if the file extension is hidden in the Mac UI, dragging and dropping the file on Terminal gives the correct file name for the command line.

- Phil
I don't understand either Phil. I added the .txt extension to both filename and path - and no - it makes NO sense to have a file with a "double" extension like .fmt.txt. I'm sure it's not an issue with ExifTool, but something weird going on in my system. I'm happy to carry out some tests if you want to dig into it. But otherwise, I'm just happy I found a tool that could compile the list of coordinates I needed :)

Phil Harvey

OK, so the tests.

1. Rename the gpx.fmt.txt file back to gpx.fmt

2. What is the output if you do this?:

exiftool DRAG_AND_DROP_GPX.FMT_HERE

3. If the above works (and gives a word and line count), confirm that your original command still doesn't work when dragging and dropping the gpx.fmt file.

- 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 ($).

TrackGen

Quote from: Phil Harvey on January 04, 2023, 01:54:27 PMOK, so the tests.

1. Rename the gpx.fmt.txt file back to gpx.fmt
Re-downloaded a "clean" files from the Github link earlier in this thread - just to be sure, there was nothing weird with my file.

Quote from: Phil Harvey on January 04, 2023, 01:54:27 PM2. What is the output if you do this?:
exiftool DRAG_AND_DROP_GPX.FMT_HERE
Output is:
ExifTool Version Number         : 12.52
File Name                       : gpx.fmt
Directory                       : /Users/Me/Desktop/GPX/test
File Size                       : 1849 bytes
File Modification Date/Time     : 2023:01:05 20:25:35+01:00
File Access Date/Time           : 2023:01:05 20:25:38+01:00
File Inode Change Date/Time     : 2023:01:05 20:25:37+01:00
File Permissions                : -rw-r--r--
File Type                       : TXT
File Type Extension             : txt
MIME Type                       : text/plain
MIME Encoding                   : us-ascii
Newlines                        : Unix LF
Line Count                      : 39
Word Count                      : 191


Quote from: Phil Harvey on January 04, 2023, 01:54:27 PM3. If the above works (and gives a word and line count), confirm that your original command still doesn't work when dragging and dropping the gpx.fmt file.
....awkward silence. It now creates a file with perfectly extracted geo data..
What in the world?!?! I don't get it. All I can think of is something went wrong in my original download of the gpx.fmt file..? Wow! Crazy stuff :)

Phil Harvey

This is what I expected should happen.  There was something wrong with the earlier commands.  Even if there was a problem with gpx.fmt you wouldn't have seen the earlier symptoms.

OK.  So things are now working as expected. :)

- 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 ($).