Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Re: Use perl to extract GPS coordinates from a cell phone image.

by tobyink (Abbot)
on Jan 02, 2013 at 07:20 UTC ( #1011219=note: print w/replies, xml ) Need Help??

in reply to Use perl to extract GPS coordinates from a cell phone image.

use 5.010; use strict; use warnings; use Image::ExifTool ':Public'; my $filename = "MyImage.jpeg"; my $metadata = ImageInfo $filename; say "Latitude: ", $metadata->{GPSLatitude}; say "Longitude: ", $metadata->{GPSLongitude}; say "Altitude: ", $metadata->{GPSAltitude}; say "DateTime: ", $metadata->{GPSDateTime};

Works for my phone; different phones may set different EXIF keys, so you may need to experiment a little.

perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'

Replies are listed 'Best First'.
Re^2: Use perl to extract GPS coordinates from a cell phone image.
by flexvault (Monsignor) on Jan 06, 2013 at 15:29 UTC

    Hello tobyink,

    ++ for a great response. I have tried using your sample script and everything works great, except I have yet to see GPS data results. I reread the CPAN docs for 'Image::ExifTool' and it references a config file and was wondering if you had defined a config file?

    I'm using a LG LS670 phone camera with GPS on, as well as checking some apple camera pictures that show GPS info. (Friend sent pictures to me, so I hope the pictures actually have the GPS info embedded).

    Any ideas appreciated.

    Thank you...Ed

    "Well done is better than well said." - Benjamin Franklin

      Works out of the box for me. (HTC Explorer phone, Android 2.3.)

      You could try throwing $metadata at Data::Dumper to see what's inside...

      use Data::Dumper; print Dumper ImageInfo "MyImage.jpeg";
      perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'


        Thanks for the suggestion (which I tried), but neither picture had any GPS info. I'm running Android 2.3, so I'm going to assume that the camera's aren't set up correctly.


        "Well done is better than well said." - Benjamin Franklin

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1011219]
[Corion]: ... and I still don't understand why ;)
[Corion]: This is because Filter::Simple does some string-trickery, replacing all string literals with "quoted packed numbers"
[Corion]: I fear this might be a bug in the RE engine, but if it is a bug, even fixing won't help me because I need Filter::Simple for Filter::signatures , which provides signatures as a backwards compatibility feature for Perl <5.22 - and these ...
[Corion]: ... won't get a fix anyway ;) My plan B is to encode the string placeholders avoiding \r and \n
Discipulus spent his sathurday repairing a fontain in agarden to save red fishes inside it..

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (12)
As of 2017-01-23 08:06 GMT
Find Nodes?
    Voting Booth?
    Do you watch meteor showers?

    Results (191 votes). Check out past polls.