A Windows shell extension that adds a context menu item to copy the GPS location data from a JPG image to the clipboard and shows a toast notification with handy links to the location in Google Maps and Gaia GPS.
Although the file properties dialog can display the GPS coordinates of an image in File Explorer, there is no way to copy it to the clipboard, making it painful to try to view the location in a service like Google Maps or Gaia GPS.
The built-in Photos app in Windows does show a tiny map when you right-click the image and choose File Info, but there is no way to make the image bigger, open the location in another window or copy the GPS coordinates. It's almost useless.
In short, I need a way to quickly extract the location from a photo and view its location on a map, especially Google Maps and Gaia GPS.
It consists of a short PowerShell script that extracts the GPS location data from a .jpg or .jpeg image, copies it to the
clipboard, and shows a Windows Toast Notification in the lower right corner. The script is triggered by a right-click
menu option that appears in File Explorer. This menu option is added by configuring a shell extension in the
SystemFileAssociations
section of the Windows registry.
- Windows 10 and higher
- BurntToast - PowerShell Module for displaying Windows Toast Notifications. See below for installation instructions.
There are three steps. Detailed instructions below.
- Install BurntToast if not already installed.
- Copy
copy-gps.ps1
somewhere on your PC. - Add the registry settings that create the right-click menu option for .jpg and .jpeg files in File Explorer.
-
Open a PowerShell Window with administrative permission.
-
Type
Install-Module -Name BurntToast
and follow the prompts to complete the installation.
- Copy
copy-gps.ps1
from this repository to somewhere on your PC. Or just clone it.
The repository contains a file that will automatically add the context menu command for .jpg and .jpeg files. If you prefer to update the registry manually, use option 2.
-
Open
register-copygps-for-jpg-and-jpeg.reg
in a text editor and update the path tocopy-gps.ps1
to the location you copied to. -
Execute the file by double-clicking it in File Explorer.
Follow these steps to manually add the keys.
-
Use
regedit.exe
to navigate toHKEY_CLASSES_ROOT\SystemFileAssociations\.jpg\Shell
. -
Add a new key named
copy-gps
with the value "Copy GPS coordinates". This is the text that will appear in the right-click menu. -
Add a child key beneath
copy-gps
namedCommand
. Set the value topowershell.exe -File "C:\Dev\copy-gps\copy-gps.ps1" "%1"
, updating the path as needed. -
Repeat the above steps for the .jpeg file extension.
-
In File Explorer, hold the shift key and right-click a .jpg or .jpeg image and click Copy GPS coordinates.
💡 TIP: Alternatively, you can right-click, then choose Show More Options.
-
A PowerShell window will briefly appear and close, following by a Windows Toast Notification.
-
If the image does not contain GPS data, this message will appear:
-
Notifications must be enabled for the notification to appear. To enable, go to Settings > System > Notifications. Regardless of this setting, the GPS coodinates are copied to the clipboard.
-
The toast notification may not appear if the do not disturb setting is enabled (Windows 11) or Focus Assist is set to Priority Only or Alarms Only (Windows 10). In these cases, the message is sent directly to the notification center and not displayed as a popup. Note that the buttons that open Google Maps and Gaia are not shown in the notification center. To allow the popup to appear, turn off Focus Assist or add PowerShell as a priority app.
-
You may need to restart File Explorer for the registry changes to take effect.
-
Remember to hold the shift key when you right-click to see the menu option.
-
The notification includes buttons that open Google Maps and Gaia GPS in the default browser. Edit the PowerShell script if you wish to modify this behavior.
-
If the browser is currently hidden, clicking one of the buttons does not bring it to the foreground, so you may have to manually switch to the browser window. This is default PowerShell behavior. There are hacks for dealing with it, but I didn't go down that road.
-
One can avoid the BurntToast dependency by creating the toast manually, but achieving the same functionality (thumbnail image and action buttons) is more difficult. For example, to create a plain text notification, this code can be used as a starter. Credit to Den Delimarsky.
function Show-Notification {
[cmdletbinding()]
Param (
[string]
$ToastTitle,
[string]
[parameter(ValueFromPipeline)]
$ToastText
)
[Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] > $null
$Template = [Windows.UI.Notifications.ToastNotificationManager]::GetTemplateContent([Windows.UI.Notifications.ToastTemplateType]::ToastText02)
$RawXml = [xml] $Template.GetXml()
($RawXml.toast.visual.binding.text|where {$_.id -eq "1"}).AppendChild($RawXml.CreateTextNode($ToastTitle)) > $null
($RawXml.toast.visual.binding.text|where {$_.id -eq "2"}).AppendChild($RawXml.CreateTextNode($ToastText)) > $null
$SerializedXml = New-Object Windows.Data.Xml.Dom.XmlDocument
$SerializedXml.LoadXml($RawXml.OuterXml)
$Toast = [Windows.UI.Notifications.ToastNotification]::new($SerializedXml)
$Toast.Tag = "PowerShell"
$Toast.Group = "PowerShell"
$Toast.ExpirationTime = [DateTimeOffset]::Now.AddMinutes(1)
$Notifier = [Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier("PowerShell")
$Notifier.Show($Toast);
}