22

I have taken some photos on my Ubuntu machine, and I'd like to know whether they contain geolocation, and if so, what are they.

How can I do that?

wbad
  • 587
  • 1
  • 6
  • 17
  • This depends on the software you used. What software _did_ you use? – forest Oct 17 '18 at 01:35
  • 1
    Ever see this website (platform independent)? http://exif.regex.info/exif.cgi *Note: you are uploading your photos to a third party, make sure you are OK with them being on the front page of the Sunday Times **before** uploading.* – HashHazard Oct 17 '18 at 02:37
  • Related, but on a different site, and not quite the same: [AskUbuntu: Command to see media file info in terminal?](https://askubuntu.com/questions/249828/command-to-see-media-file-info-in-terminal). – Gabriel Staples Mar 06 '21 at 23:13

3 Answers3

32

exiftool can be used to print out the metadata of the image. If the location was stored when the image was taken (usually called 'geotagging'), you can find it there:

$ exiftool 23.jpg  | grep GPS
GPS Latitude Ref                : North
GPS Longitude Ref               : East
GPS Latitude                    : 35 deg 32' 16.80" N
GPS Longitude                   : 139 deg 29' 49.20" E
GPS Position                    : 35 deg 32' 16.80" N, 139 deg 29' 49.20" E
$

You can also use exiftool to strip the GPS information out of an existing image:

$ exiftool -gps:all= 23.jpg
    1 image files updated
$ exiftool 23.jpg | grep GPS
$

Any tool that can look at image metadata can look at this information. For example, the identify tool from ImageMagic will also do it:

$ identify -verbose 23.jpg | grep GPS
    exif:GPSInfo: 640
    exif:GPSLatitude: 35/1, 3228/100, 0/1
    exif:GPSLatitudeRef: N
    exif:GPSLongitude: 139/1, 2982/100, 0/1
    exif:GPSLongitudeRef: E
$

and GUI tools can often do so as well - here's Image Viewer from Ubuntu 18:

Image Viewer Details/Metadata

Many images do not have GPS entries in their metadata - for example, if you take a picture with a camera that doesn't have GPS, it won't store it - here's a list of cameras that do have GPS.

Most cell phones, of course, have a GPS, and often will geotag by default. You can choose to disable this in Android and iPhones.

gowenfawr
  • 1,767
  • 11
  • 12
4

This command will check your photos in a directory and looks up whether Geo tags are saved in Exif. It will report those where data was found:

for f in *.jpg; do CMD="$(exiftool -a -gps:all "$f" 2>/dev/null | grep "GPS Latitude")"; RET=$?; if [ "$RET" -eq "0" ]; then echo "$f"; fi; done

If you want to automatically parse the geo information in computer-readable format in order to further process the coordinates, you can use this

exiftool -c "%+.6f" "$1" |grep "GPS Position" | cut -d":" -f2 | tr -d ' '

This tool (bash script) does it automatically on the file that is passed to it as argument: https://gist.github.com/pas-calc/0e6063affa749fedc2e51cea88345929 . The results will be displayed on the Geo Tool website.

pas-calc
  • 43
  • 2
0

In case your file manager is Nemo, then a pluggable action collection may help: https://github.com/s-n-ushakov/exif-gps-mapping-nemo . It allows displaying Exif metadata of media files in popup windows in Nemo, as well as displaying shooting locations in OpenStreetMap, Google Maps or whatever. Screenshots are available there in README...