Store GPSlocation from Google Maps into EXIF header fields of JPG photo file ?

Started by pstein, June 19, 2024, 01:43:45 PM

Previous topic - Next topic

pstein

Occasionally I get *.jpg photos file which were taken while the GPS feature was disabled in smartphone.
Or older photos from digital cameras without a GPS function.

Now I want to assign the approximate GPS location afterwards into the GPSlocation fields in EXIF header.

Therefore my plan is to find the location in Google Maps in browser, then somehow pin it and copy the link to pin to clipboard and finally assign this in ExifToolGUI.

Is this possible?

StarGeek

You don't need to create a pin.  If you right click on a Google map, a context menu pops up and the first entry is the GPS coordinates of that location
firefox-2024-06-19_17.14.18.png

If you click on that, those coordinates are copied to the clipboard.

You can then write those coordinates to the GPSPosition which will write the data to the appropriate locations.
C:\>exiftool -P -overwrite_original -GPSPosition="40.68925584928791, -74.04462817764629" y:\!temp\Test4.jpg
    1 image files updated

C:\>exiftool -G1 -a -s -gps* y:\!temp\Test4.jpg
[GPS]           GPSVersionID                    : 2.3.0.0
[GPS]           GPSLatitudeRef                  : North
[GPS]           GPSLatitude                     : 40 deg 41' 21.32"
[GPS]           GPSLongitudeRef                 : West
[GPS]           GPSLongitude                    : 74 deg 2' 40.66"
[Composite]     GPSLatitude                     : 40 deg 41' 21.32" N
[Composite]     GPSLongitude                    : 74 deg 2' 40.66" W
[Composite]     GPSPosition                     : 40 deg 41' 21.32" N, 74 deg 2' 40.66" W

Though I don't know how you would do it in the GUI.

I just noticed that the number copied to the clipboard has a lot more decimal numbers than what is displayed.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

pstein

@Stargeek:

Thank you for your suggestion.

The first part with Google Maps context menu looks good and it works.

Furthermore a command line command to apply this location is acceptable as well (its even better than GUI).

Unfortunately it does not work (as intended).

When I apply a GPS location to a *.mp4 video file then the location is written to:

group: XMP-exif
GPSLatitude
and
GPSLongitude

What I need is a storing in

group: UserData
GPSCoordinates

How can I achieve this?

Ok, my original headline is misleading since I asked only for JPGs.
So let me ask again for MP4 too


Phil Harvey

Change GPSPosition to GPSCoordinates in the command if you want to write GPSCoordinates.

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

StarGeek

Quote from: pstein on June 20, 2024, 06:46:56 AMWhat I need is a storing in

group: UserData
GPSCoordinates

How can I achieve this?

You would change it to
-UserData:GPSCoordinates="40.689, -74.0454"
because otherwise exiftool will write to ItemList:GPSCoordinates
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

Phil Harvey

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

pstein

Quote from: StarGeek on June 20, 2024, 12:02:28 PMYou would change it to
-UserData:GPSCoordinates="40.689, -74.0454"

Yes, I am aware of this

Everything works now.
Many thanks

pstein

Everything above works....except one thing:

If the target *.jpg file does NOT already contain a "GPS" group then adding

-GPS:GPSPosition=.......

does not work either. exiftool complains about
"Warning: Sorry, GPS:GPSPosition doesn't exist or isn't writable
Nothing to do."

I guess I have to create the group "GPS" at first before adding tag inside the group.
How can I achieve this?

Can I do this with one command?

Phil Harvey

GPSPosition does not belong to the GPS group.  It is a Composite tag.  So either drop the "GPS:", or change it to "Composite:".

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

StarGeek

My advice is to keep tag names simple when possible. GPSPosition is the only tag with that name, so there isn't a need to explicitly state the Composite group.

Your need to use UserData:GPSCoordinates is one of the uncommon cases of when there is a need to use the exact group name.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

pstein

Ok, thank you.

So if I right-click on a certain position in Google Maps and select (as you suggested) the current position.
then I have something like

1.2941987121780796, 103.85531059641615

in clipboard.

How can I (automatically!) split this double-value into a GPSLatitude and a second GPSLangitude part and assign it into (currently non-existing) GPS:Latitude and GPS:Longitude Exif tags of a JPG file?

Can I assign it alternatively to UserData:GPSCoordinates (which contains double values as in clipboard)
Or does this actual MP4 header tag in JPG files could confuse later JPG image editors?

StarGeek

Quote from: pstein on July 01, 2024, 05:54:55 AMSo if I right-click on a certain position in Google Maps and select (as you suggested) the current position.
then I have something like

1.2941987121780796, 103.85531059641615

in clipboard.

How can I (automatically!) split this double-value into a GPSLatitude and a second GPSLangitude part and assign it into (currently non-existing) GPS:Latitude and GPS:Longitude Exif tags of a JPG file?

Look back at my first post in this thread where I gave an example. You assign it to GPSPosition for JPEGs or other image files. There's no need to split it. Just type
-GPSPosition="
then paste with Control+V, then a closing quote.

QuoteCan I assign it alternatively to UserData:GPSCoordinates (which contains double values as in clipboard)
Or does this actual MP4 header tag in JPG files could confuse later JPG image editors?

No, you can't place Quicktime data into a JPEG (or PNG/TIFF) file. It can go into HEIC/CR3 files, as those are based upon the MP4 format, but in those cases you should give priority to the EXIF locations by using GPSPosition, not the Quicktime ones.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

pstein

Quote from: StarGeek on July 01, 2024, 10:26:13 AMLook back at my first post in this thread where I gave an example. You assign it to GPSPosition for JPEGs or other image files. There's no need to split it. Just type
-GPSPosition="
then paste with Control+V, then a closing quote.

Meanwhile I found the problem but not a solution.

If the target *.jpg file

1.) .... already contains "GPS" grouo (with GPSLatitude and GPSLongitude tags inside) then I have to write
    -GPS:GPSPosition=....    (to update the GPSLatitude and GPSLongitude tags inside)
2.) .....contains NO GPS group I have to write
    -GPSPosition=.....
      (WITHOUT prepended "GPS:" group) to create GPS: tags
but
3.) .....contains NO GPS group and I write -GPS:GPSPosition=..... then the command fails.

So I always have to manually check at first whether the *.jpg file already contains a group "GPS" or not.
Very unhandy and uncomfortable.

Is there a parameter which fits for both types of *.jpg files?

Phil Harvey

Quote from: pstein on July 03, 2024, 07:07:34 AM1.) .... already contains "GPS" grouo (with GPSLatitude and GPSLongitude tags inside) then I have to write
    -GPS:GPSPosition=....    (to update the GPSLatitude and GPSLongitude tags inside)

No.  With this, you should get the warning:

Warning: Sorry, GPS:GPSPosition doesn't exist or isn't writable
Quote2.) .....contains NO GPS group I have to write
    -GPSPosition=.....
      (WITHOUT prepended "GPS:" group) to create GPS: tags

This is what you should be doing always.

Quote3.) .....contains NO GPS group and I write -GPS:GPSPosition=..... then the command fails.

This will always fail.  (Why aren't you seeing the warnings?)

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

StarGeek

Quote from: pstein on July 03, 2024, 07:07:34 AM2.) .....contains NO GPS group I have to write
    -GPSPosition=.....
      (WITHOUT prepended "GPS:" group) to create GPS: tags
but
3.) .....contains NO GPS group and I write -GPS:GPSPosition=..... then the command fails.

Please take the time to read what we post. Phil said

Quote from: Phil Harvey on June 30, 2024, 09:02:50 AMGPSPosition does not belong to the GPS group.  It is a Composite tag.  So either drop the "GPS:", or change it to "Composite:".

But you keep insisting on putting GPS in front of it. Keep the names simple. Don't include the group name unless you actually need it, which you don't in your commands.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype