ExifTool Forum

ExifTool => Newbies => Topic started by: pstein on June 19, 2024, 01:43:45 PM

Title: Store GPSlocation from Google Maps into EXIF header fields of JPG photo file ?
Post by: pstein on June 19, 2024, 01:43:45 PM
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?
Title: Re: Store GPSlocation from Google Maps into EXIF header fields of JPG photo file ?
Post by: StarGeek on June 19, 2024, 08:21:17 PM
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.
Title: Re: Store GPSlocation from Google Maps into EXIF header fields of JPG photo file ?
Post by: pstein on June 20, 2024, 06:46:56 AM
@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

Title: Re: Store GPSlocation from Google Maps into EXIF header fields of JPG photo file ?
Post by: Phil Harvey on June 20, 2024, 06:59:53 AM
Change GPSPosition to GPSCoordinates in the command if you want to write GPSCoordinates.

- Phil
Title: Re: Store GPSlocation from Google Maps into EXIF header fields of JPG photo file ?
Post by: StarGeek on June 20, 2024, 12:02:28 PM
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
Title: Re: Store GPSlocation from Google Maps into EXIF header fields of JPG photo file ?
Post by: Phil Harvey on June 20, 2024, 08:35:45 PM
Thanks.  Good point.

- Phil
Title: Re: Store GPSlocation from Google Maps into EXIF header fields of JPG photo file ?
Post by: pstein on June 21, 2024, 02:00:46 AM
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
Title: Re: Store GPSlocation from Google Maps into EXIF header fields of JPG photo file ?
Post by: pstein on June 30, 2024, 08:14:50 AM
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?
Title: Re: Store GPSlocation from Google Maps into EXIF header fields of JPG photo file ?
Post by: Phil Harvey on June 30, 2024, 09:02:50 AM
GPSPosition does not belong to the GPS group (https://exiftool.org/TagNames/GPS.html).  It is a Composite (https://exiftool.org/TagNames/Composite.html) tag.  So either drop the "GPS:", or change it to "Composite:".

- Phil
Title: Re: Store GPSlocation from Google Maps into EXIF header fields of JPG photo file ?
Post by: StarGeek on June 30, 2024, 09:58:32 AM
My advice is to keep tag names simple (https://exiftool.org/forum/index.php?msg=80202) 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.
Title: Re: Store GPSlocation from Google Maps into EXIF header fields of JPG photo file ?
Post by: pstein on July 01, 2024, 05:54:55 AM
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?
Title: Re: Store GPSlocation from Google Maps into EXIF header fields of JPG photo file ?
Post by: StarGeek on July 01, 2024, 10:26:13 AM
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 (https://exiftool.org/forum/index.php?msg=86794) 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.
Title: Re: Store GPSlocation from Google Maps into EXIF header fields of JPG photo file ?
Post by: pstein on July 03, 2024, 07:07:34 AM
Quote from: StarGeek on July 01, 2024, 10:26:13 AMLook back at my first post (https://exiftool.org/forum/index.php?msg=86794) 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?
Title: Re: Store GPSlocation from Google Maps into EXIF header fields of JPG photo file ?
Post by: Phil Harvey on July 03, 2024, 07:20:08 AM
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
Title: Re: Store GPSlocation from Google Maps into EXIF header fields of JPG photo file ?
Post by: StarGeek on July 03, 2024, 11:07:53 AM
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 (https://exiftool.org/TagNames/GPS.html).  It is a Composite (https://exiftool.org/TagNames/Composite.html) 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.
Title: Re: Store GPSlocation from Google Maps into EXIF header fields of JPG photo file ?
Post by: pstein on July 11, 2024, 02:52:05 AM
Ok works.
Thank you all