Saturday, November 6, 2010

Retrieving Exif data, or Where she at bro?




Geolocation data in some cameras and many smart phones is embedded in the photos that these devices take.


View Larger Map


**Technical information**

The incredibly simple script **must install Image::ExifTool**
Image::ExifTool can be installed rather easily, through cpan.

use Image::ExifTool qw(:Public);
my $info = ImageInfo("$ARGV[0]");

foreach (keys %$info) {
print "$_ => $$info{$_}\n";
}

run it like this:
perl meta.pl test3.jpg

Output for this looks like:

GPSLatitude (1) => 43 deg 49' 42.60"
GPSLatitude => 43 deg 49' 42.60" N
GPSLongitudeRef => West
GPSTimeStamp => 01:00:12.48
GPSLatitudeRef => North
GPSLongitude => 79 deg 7' 24.00" W
GPSPosition => 43 deg 49' 42.60" N, 79 deg 7' 24.00" W
GPSLongitude (1) => 79 deg 7' 24.00"
lane@skullfuckerthemagnificent:~/Pictures$ perl meta.pl test27.jpg
XResolution (1) => 1
ImageWidth => 600
Model => iPhone
ExifImageHeight => 1600
GPSLatitude (1) => 43 deg 49' 42.60"
ResolutionUnit => inches
ColorComponents => 3
BitsPerSample => 8
GPSLatitude => 43 deg 49' 42.60" N
MIMEType => image/jpeg
FileType => JPEG
GPSLongitudeRef => West
ResolutionUnit (1) => None
ExifToolVersion => 8.25
FilePermissions => rw-r--r--
JFIFVersion => 1.02
Directory => .
FileName => test27.jpg
ImageHeight => 800
XResolution => 72
Make => Apple
DateTimeOriginal => 2009:04:08 01:00:13
GPSTimeStamp => 01:00:12.48
CreateDate => 2009:04:08 01:00:13
YCbCrSubSampling => YCbCr4:4:0 (1 2)
ExifByteOrder => Little-endian (Intel, II)
FileModifyDate => 2010:10:22 07:43:26-05:00
ExifImageWidth => 1200
ColorSpace => sRGB
EncodingProcess => Baseline DCT, Huffman coding
FileSize => 58 kB
YResolution => 72
Aperture => 2.8
GPSLatitudeRef => North
GPSLongitude => 79 deg 7' 24.00" W
GPSPosition => 43 deg 49' 42.60" N, 79 deg 7' 24.00" W
YResolution (1) => 1
FNumber => 2.8
ModifyDate => 2009:04:08 01:00:13
GPSLongitude (1) => 79 deg 7' 24.00"
ImageSize => 600x80

and if you have linux, mac, or your operating from within cygwin on windows this helps:

perl meta.pl test3.jpg | grep 'GPS'

Output for this will look like:

GPSLatitude (1) => 43 deg 49' 42.60"
GPSLatitude => 43 deg 49' 42.60" N
GPSLongitudeRef => West
GPSTimeStamp => 01:00:12.48
GPSLatitudeRef => North
GPSLongitude => 79 deg 7' 24.00" W
GPSPosition => 43 deg 49' 42.60" N, 79 deg 7' 24.00" W
GPSLongitude (1) => 79 deg 7' 24.00"


GPSPosition is the one your looking for you will need to trim it for google maps(IE 43 49' 42.60" N, 79 7' 24.00" W).


Most photos that get uploaded to the intarwebs get altered by resizing software or watermarking software or what not. When these photos are altered, many times thier EXIF information is cleared and replaced with information about the software that has done this(ie imagemagic GD). So most photos are not very useful. Sites that might be useful are probably twitter related image storage sites, simply because they consider stuff like geotags valuable.

1 comment:

Xero said...

Oh snap. Now you can get the 411 on all the honeys. Good luck to you.