Shows picture exif GPS info if any and converts coords to a decimal degree number

identify -verbose my_image.jpg | awk 'function cf(i){split(i,a,"/");if(length(a)==2){return a[1]/a[2]}else{return a[1]}}/GPS/{if($1~/GPSLatitude:|GPSLongitude:/){s=$0;gsub(/,/,"",$0);printf("%s (%f)\n", s, $2+cf($3)/60+cf($4)/3600)}else{print}}'
This oneliner uses Imagemagic's identify utility to show the exif GPS information of an image an also converts Grad/MIn/Sec representation to a decimal degree number
Sample Output
    exif:GPSAltitude: 1665000/1000
    exif:GPSAltitudeRef: 0
    exif:GPSDateStamp: 2017:10:25
    exif:GPSInfo: 3166
    exif:GPSLatitude: 47/1, 39/1, 403802/10000  (47.661217)
    exif:GPSLatitudeRef: N
    exif:GPSLongitude: 11/1, 47/1, 374272/10000  (11.793730)
    exif:GPSLongitudeRef: E
    exif:GPSMapDatum: WGS-84
    exif:GPSProcessingMethod: ASCII
    exif:GPSTimeStamp: 10/1, 32/1, 53/1
    exif:GPSVersionID: 2, 2, 0, 0

5
By: ichbins
2022-02-20 10:17:49

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: