CC snippet - EXIF GPS coordinates

Discuss and share scripts and script files...
highend
Posts: 14571
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

CC snippet - EXIF GPS coordinates

Post by highend »

How to set up a custom column with a snippet: viewtopic.php?f=7&t=18653

This one displays the EXIF GPS coordinates of all .jpg and .tiff files in a folder in a custom column.

It does not require external tools like exiv2 (http://www.exiv2.org/index.html)

The snippet code:

Code: Select all

Snip: CustomColumn 1
  XYplorer 26.50.0004, 10.10.2024 09:45:38
Action
  ConfigureColumn
Caption
  GPS
Type
  3
Definition
      $latitude  = get("exif", 0x0002, <cc_item>); // 52/1 13/1 85053/2500  => 52° 13' 34.02"N => 52.2261166667
      $longitude = get("exif", 0x0004, <cc_item>); // 13/1 13/1 134931/2500 => 13° 13' 53.97"E => 13.2316583333
      if ($latitude == "" || $longitude == "") { return "<no gps coordinates>"; }
  
      $latRef      = get("exif", 0x0001, <cc_item>); // N / S
      $longRef     = get("exif", 0x0003, <cc_item>); // W / E
      $latDegree   = gettoken(gettoken($latitude, 1), 1, "/");
      $latMinutes  = gettoken(gettoken($latitude, 2), 1, "/");
      $latSeconds  = replace(round(eval(gettoken($latitude, 3)), 2), ",", ".");
      $longDegree  = gettoken(gettoken($longitude, 1), 1, "/");
      $longMinutes = gettoken(gettoken($longitude, 2), 1, "/");
      $longSeconds = replace(round(eval(gettoken($longitude, 3)), 2), ",", ".");
  
      return $latDegree . "° " . $latMinutes . "' " . $latSeconds . '"' . $latRef . "  ". $longDegree . "° " . $longMinutes . "' " . $longSeconds . '"' . $longRef;
Format
  0
Trigger
  0
Item Type
  0
Item Filter
  jpg;tiff
It looks like this:
cc_setup.png
cc_setup.png (16.72 KiB) Viewed 4973 times
One of my scripts helped you out? Please donate via Paypal

Alan_CLarke59
Posts: 1
Joined: 15 Mar 2019 15:29

Re: CC snippet - EXIF GPS coordinates

Post by Alan_CLarke59 »

Hi All,
This function is exactly what I need, however, I can't get it to work.
I am following the instructions correctly I believe, but no success.

This is the exif data from my picture:
Image

Can anyone help please?


Regards,

Alan C

highend
Posts: 14571
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: CC snippet - EXIF GPS coordinates

Post by highend »

There is no image...
One of my scripts helped you out? Please donate via Paypal

admin
Site Admin
Posts: 64900
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: CC snippet - EXIF GPS coordinates

Post by admin »

Strange, but you can right-click the word "Image" to show the image... :?

highend
Posts: 14571
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: CC snippet - EXIF GPS coordinates

Post by highend »

Mh, not here. Regardless of any exif data, what exactly does the custom column show? Provide a picture^^
One of my scripts helped you out? Please donate via Paypal

Mr_Inc
Posts: 13
Joined: 27 Sep 2010 13:17

Re: CC snippet - EXIF GPS coordinates

Post by Mr_Inc »

Holy thread resurrection.......!

I stumbled across this suggestion for a Custom Column and got it to work nicely as described (with a couple of formatting amendments in the script to make it Google Maps URL friendly).

Image

How could this GPS column/data be made to open Google maps and append the GPS 'data' in the column to this URL https://www.google.com/maps/place/ and make it a clickable link to open in a browser?

I am not sure if it can be done in the Custom Column itself or whether a TAG needs to be generated using the data in the GPS column.

Any ideas would be welcome!

Thanks.

highend
Posts: 14571
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: CC snippet - EXIF GPS coordinates

Post by highend »

You can't do this in the same column but you could add another one with a Trigger set to "Click" (which adds a button) to it.

Clicking that button would then execute a script that gets a report() from the current pane and then you have to parse it, dissect the content of your GPS column, calculate the decimal degrees value, construct the url for google maps and open it.

Easily done but it requires scripting knowledge^^

As a starting point to get the correct content of the belonging custom column when clicking the button:

Code: Select all

    $report = report("{FullName}|{GPS}<crlf>");
    $esc    = regexreplace(<cc_item>, "([\\^$.+()\[{])", "\$1");
    $gps    = regexmatches($report, "^" . $esc . "\|.*?$", , 1);
    $gps    = gettoken($gps, 2, "|");
    open "https://www.google.com/maps/place/" . $gps;
Btw, I've updated the snippet in the first post to look more like this:

Code: Select all

52° 13' 34.02"N  13° 13' 53.97"E
One of my scripts helped you out? Please donate via Paypal

Mr_Inc
Posts: 13
Joined: 27 Sep 2010 13:17

Re: CC snippet - EXIF GPS coordinates

Post by Mr_Inc »

Thanks for the reply.

Google Maps can accept locations directly in Degrees Minutes and Seconds format without resorting to converting to decimal.

So I just replaced the last line with:

Code: Select all

open 'https://www.google.com/maps/place/'.$gps;
and it worked a treat! Yay!

admin
Site Admin
Posts: 64900
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: CC snippet - EXIF GPS coordinates

Post by admin »

Cool. :tup:

phred
Posts: 557
Joined: 26 Dec 2021 02:10
Location: XY 64bit on Windows 10 at 100% from Boston USA

Re: CC snippet - EXIF GPS coordinates

Post by phred »

Thanks to highend for the original snippet and tip to get a button to paste/open the coordinates. And to Mr_Lee for the modification to get it to open in Google Maps.

I now have saved both both columns in a column layout, which I can load whenever I'm in a directory of photos. There is one further enhancement I'd like to add but I haven't found how to accomplish it when searching through the massive PDF user manual. Is there a way to add this specific column layout to a toolbar button?

Thanks.

highend
Posts: 14571
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: CC snippet - EXIF GPS coordinates

Post by highend »

columnlayout()...
One of my scripts helped you out? Please donate via Paypal

phred
Posts: 557
Joined: 26 Dec 2021 02:10
Location: XY 64bit on Windows 10 at 100% from Boston USA

Re: CC snippet - EXIF GPS coordinates

Post by phred »

Thanks highend.

I've now been able to find it in the user manual. Following what you showed, I've got the Columns directory opening on a click of the button. Now I'm trying to simply one the column layout I've created for the coordinates and map button.

Per the user manual, I should be entering

Code: Select all

columnlayout(file, [mode="load"])
When I enter

Code: Select all

columnlayout(D:\Utilities\XYplorer\Columns\gps + map location.txt)
the script crashes with an overflow error. I also tried

Code: Select all

columnlayout(D:\Utilities\XYplorer\Columns\gps + map location.txt, "load");
with the same overflow error.

Would you kindly show me what I'm doing wrong?

Thanks again.

highend
Posts: 14571
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: CC snippet - EXIF GPS coordinates

Post by highend »

Quote your paths? oO

Save the layout while you're showing the GPS + button column:

Code: Select all

columnlayout("D:\Utilities\XYplorer\Columns\gps + map location.txt", "save");
And then, whenever you need it elsewhere, load it:

Code: Select all

columnlayout("D:\Utilities\XYplorer\Columns\gps + map location.txt");
One of my scripts helped you out? Please donate via Paypal

phred
Posts: 557
Joined: 26 Dec 2021 02:10
Location: XY 64bit on Windows 10 at 100% from Boston USA

Re: CC snippet - EXIF GPS coordinates

Post by phred »

highend wrote: 10 Oct 2024 23:01 Quote your paths? oO
So simple! I'm embarrassed to admit I should've tried that before posting.
And I've got the Save and Load under control.

Thanks again, highend.

admin
Site Admin
Posts: 64900
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: CC snippet - EXIF GPS coordinates

Post by admin »

The next beta will make that column definition a lot simpler:

Code: Select all

return get("exif", "gps", <cc_item>);
:)

Post Reply