Skip to content

Instantly share code, notes, and snippets.

@TmanTman
Last active February 10, 2024 21:39
Show Gist options
  • Save TmanTman/952a95e253f0d0385ee8e89d51734341 to your computer and use it in GitHub Desktop.
Save TmanTman/952a95e253f0d0385ee8e89d51734341 to your computer and use it in GitHub Desktop.
Assigns a GPS location to an image. Requires exiftool to be installed. Copy the GPS locations from Google Maps.
# Example usage: sh set-gps-location.sh test.JPG "-32.326510, 19.020942"
if [ -z "$1" ] ; then
echo 'Image filename needs to be provided. Exiting'
exit 1
fi
if [ -z "$2" ] ; then
echo 'Comma-separated list of GPS coords ( lat,lng ) needs to be supplied. Exiting'
exit 1
fi
# https://stackoverflow.com/questions/918886/how-do-i-split-a-string-on-a-delimiter-in-bash
gpsLocationInput=$2
gpsLocationNoWhiteSpace=(${gpsLocationInput// /})
gpsLocationLatLng=(${gpsLocationNoWhiteSpace//,/ })
echo ${gpsLocationLatLng[0]}
echo ${gpsLocationLatLng[1]}
exiftool -GPSLatitude=${gpsLocationLatLng[0]} -GPSLongitude=${gpsLocationLatLng[1]} $1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment