I have not tried the script, so there is obviously some scope for optimization. For the time being you can try this.
Considering file named coordinates
have the columns as described in the question, I have written this script accordingly.
#!/bin/bash
# Loop for every line in the coordinates file
cat coordinates | while IFS= read -r line
do
# Get Image name from Ist, Latitude from 2nd & Longitude from 3rd column.
IMAGE=`echo "$line" | awk '{print $1}'`
LAT=`echo "$line" | awk '{print $2}'`
LONG=`echo "$line" | awk '{print $3}'`
# Assign variables values into "exiftool" command
exiftool -exif:gpslatitude="$LAT" -exif:gpslatituderef=S -exif:gpdlongitude="$LONG" -exif:gpslongituderef=E "$IMAGE"
done
Some points to consider :
If exif
tags don't work for you, you may use XMP
tags. In that case the command-line would be like this :
exiftool -XMP:GPSLatitude="$LAT" -XMP:GPSLongitude="$LONG" -GPSLatitudeRef="South" -GPSLongitudeRef="East" "$IMAGE"
If you don't have References values
for GPSLatitudeRef
& GPSLongitudeRef
positions, just use -P
, and It should run fine :
exiftool -XMP:GPSLatitude="$LAT" -XMP:GPSLongitude="$LONG" -P "$IMAGE"
-P
option preserves and overwrites the values for tags passed to it, ignoring the rest of tags that are also needed.
If you wish to add more or less tags, please refer to GPS Tags.
Feel free to add in more details.