Coarse Geotagging with Bash and Google Maps

If all you want is to geotag photos with coordinates of the city where they were taken, a simple Bash shell script is all your need.

#!/usr/bin/env bash

wget -q --spider http://maps.googleapis.com/
if [ $? -ne 0 ]; then
echo "Google Maps is not reachable. Check your Internet connection."
exit 1
fi

if [ -z "$1" ]; then
echo "Please specify a city"
exit 1
fi

lat=$(curl -G -k --data "address=$1&sensor=false" http://maps.googleapis.com/maps/api/geocode/json | jq '.results[0].geometry.location.lat')
if (( $(echo "$lat > 0" |bc -l) )); then
latref="N"
else
latref="S"
fi

lon=$(curl -G -k --data "address=$1&sensor=false" http://maps.googleapis.com/maps/api/geocode/json | jq '.results[0].geometry.location.lng')
if (( $(echo "$lon > 0" |bc -l) )); then
lonref="E"
else
lonref="W"
fi
exiftool -overwrite_original -GPSLatitude=$lat -GPSLatitudeRef=$latref -GPSLongitude=$lon -GPSLongitudeRef=$lonref .

The script  obtains geographical coordinates of the specified city via Google Maps API, and then uses the ExifTool to write the obtained latitude and longitude values into photos in the current directory.

To deploy  the script, install the required packages first. To do this on openSUSE, use the following command:

sudo zypper in exiftool ImageMagick jq bc

Copy then the code, paste it into a new text file, and save the file under the geotag name. Run the commands below to install the script:

sudo cp geophotobash-simple.sh /local/bin/geotag
sudo chown root:root /local/bin/geotag
sudo sudo chmod 755 /local/bin/geotag

To geotag photos, switch to the directory in which they are stored, then run the geotag tokyo command (replace tokyo with the name of the city where the photos were taken). That’s all there is to it.

This is an excerpt from the Linux Photography book. Get your copy from Google Play Store or Gumroad.

Tagged with: , , , ,
Posted in Open Source, Photography, Software

Map Photos with uMap and PHP

If you happen to use a photo publishing application like Mejiro that stores photos and their thumbnails in regular directories, you can automatically map your photos with uMap and a dash of PHP scripting. Better still, there is no need to write PHP code from scratch: you can use a quick-and-dirty PHP script as a starting point.

Read more ›

Tagged with: , ,
Posted in Open Source, Photography, Software

Apply Multiple Hald CLUT Presets in a Single Action with a Bash Shell Script

Hald CLUT files offer a straightforward way to apply color corrections to an image (read the Linux Photography book to learn more about Hald CLUT and its usage). Install ImageMagick on your system, and you can easily apply a Hald CLUT preset to an image file using the following command:

convert foo.JPG hald-9.png -hald-clut foo-modified.jpeg

But what if you have a handful of Hald CLUT files and you want to apply them all to a specific photo?

Read more ›

Tagged with: , ,
Posted in Open Source, Photography, Scribbles, Software

WD My Passport Wireless Linux Hacks

While WD My Passport Wireless is a rather useful device in its own right, the fact that it powered by a lightweight yet complete Linux distribution means that its capabilities can be extended even further. Deploy, for example, rclone on the device, and you can back up the photos and raw files stored on the disk to any supported cloud storage service.

Read more ›

Tagged with: , , , ,
Posted in Hardware, Open Source, Software

Sonnenhut: a Script to Run before a Photo Walk

Before you head for a photo walk, it makes sense to check the weather and ensure that you won’t miss the golden hour. And Sonnenhut can help you with that. This simple Python script fetches and displays current weather conditions and golden hour info for a specified city. The script is available on GitHub under the GPLv3 license.

Read more ›

Posted in Open Source, Photography, Software

Show Geotagged Photos on OpenStreetMap

Want to show on the map the place where you took a specific photo? Provided that the photo is geotagged, the simple function below will do the job:

if [ -x "$(command -v exiftool)" ] ; then
function show-on-osm(){
lat=`exiftool -n -p '$GPSlatitude' $1`
lon=`exiftool -n -p '$GPSlongitude' $1`
osm="http://www.openstreetmap.org/?mlat=$lat&mlon=$lon&zoom=18"
xdg-open $osm
}
fi

The function extracts latitude and longitude values from the photo’s EXIF metadata, creates an OpenStreetMap URL, and opens it in the default browser.

For the function to work, you need to install the ExifTool on your system. Add the function to the ~/.bashrc file, and use the show-on-osm foo.JPG command to show the photo you want on OpenStreetMap (replace foo.JPG with the actual name of the desired photo).

This is an excerpt from the Linux Photography book. Get your copy here.

Posted in Open Source, Photography, Software

Add Captions with Basic EXIF Data to Photos using ImageMagick

Adding a caption containing basic EXIF info such as aperture, shutter speed, and ISO to a photo can come in useful in many situations. And a simple Bash shell script automates this action. The script uses the ExifTool and ImageMagick tools to extract EXIF data from a specified image. It then adds a caption containing the extracted aperture, shutter speed, and ISO values to the image.

Read more ›

Tagged with: , ,
Posted in Open Source, Scribbles, Software

Recipes for automated and streamlined photographic workflow on Linux

Practical advice for Tokyo night photography

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