Geotagging in digiKam with a Lazy Bash Script

Sometimes, the easiest way to geotag photos in digiKam is to copy and paste geographical coordinates from an existing photo. I usually use Google Photos for that, as it conveniently displays geographical coordinates of the currently viewed photos in the information sidebar.

google-photos-location

There is only one problem with this technique: copying and pasting the geographical coordinates directly doesn’t work, as digiKam expects these values to be formatted as geo:lat,long. A simple Bash shell script solves the problem.

#!/bin/bash latlon="geo:"$(xclip -o | tr -d ' ')
notify-send $latlon -i info
xclip -selection c

The script uses the xclip and tr tools to grab the contents of the clipboard (latitude and longitude values in this case) and strip the extraneous white space. The properly formatted string is then copied back into the clipboard ready to be inserted into digiKam.

Installing the script is a matter of running the following commands:

sudo cp geo /usr/local/bin/
sudo chown root:root /usr/local/bin/geo
sudo chmod 755 /usr/local/bin/geo

Next time you need to format geographical coordinates, copy them, press Alt+F2, type geo, and press Enter. Switch then to digiKam, select the photo or photos you want to geotag, and choose Item →Edit Geolocation. In the geolocation editor, select the photos, right-click on the selection, and choose Paste coordinates. Press Apply, and you’re done.

Tech writer covering Linux and open source software

Tagged with: , ,
Posted in Open Source, Photography, Software
2 comments on “Geotagging in digiKam with a Lazy Bash Script
  1. Anon says:

    If you’re on KDE, you potentially can integrate this with Klipper actions – https://docs.kde.org/trunk5/en/kde-workspace/klipper/actions.html. This way you’d only need to select the coordinates and click the pop-up menu – at least in theory, I personally don’t use this menu.

    You might want to harden your shell script or rewrite it in some other language though (c.f. shell injection).

  2. tuxflo says:

    I think the Geolocation editing in digikam should be improved at all. For example I use the Geo-Bookmarks feature a lot, I have a Lot of Bookmarks for the Locations where most of my images were taken (home, garden, friends, city…) but I’m not able to assign the Geolocation directly out of the thumbnail or table view. I always have to
    1. select the images,
    2. Open the Geolocation menu,
    3. Select all images in the menu,
    4. Rightclick and apply the bookmark,
    5. Click apply to save the changes.

    After saving the data to the images digikam needs about 10 seconds for updating the current album before I can select the next images and do the same procedure again.
    Also I don’t really understand the “Map” Feature in the right sidebar since it is greyed out if the selected image does not have any geolocation data. It would be verry helpful if one could just select some images (that are taken on a non bookmarked place) and Drag and Drop them to the Map on this sidebar to appy the Geolocation data.

    My Qt and C++ knowledge is sadly not good enough to fix this behaviour on my own but I hope the digikam devs will take a look on this soon.

Comments are closed.

Recipes for automated and streamlined photographic workflow on Linux

Curve presets for digiKam and the GIMP

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

%d bloggers like this: