Populating Geocode information from a file's Exif metadata

By sidcam - August 7, 2012

I have a real estate website. On a home's detail page I would like to have a map that centers on the listing's address then have it show pins for all the geocoded records that apply from two other sections- Neighborhood Photos and Neighborhood Videos. That way people can click to see what's around a listing. The photo and video files will be taken with a camera that has a built-in GPS to capture the geocoding information.

Question: When I upload the photos and video files to their respective sections in CMSB, is there a way to automatically populate the Longitude and Latitude info from the Exif metadata? Seems like a waste of time to have to dig into each file and copy and paste it every time.

Thanks
Sid

Re: [sidcam] Populating Geocode information from a file's Exif metadata

By Toledoh - August 7, 2012

I was looking at this the other day. I haven't progressed very far as yet, but it does look to be fairly simple.

Use the following to get a list of variables that are available to be read;
<?php
$image = "image.jpg";
$exif = exif_read_data($image, 0, true);
foreach ($exif as $key => $section) {
foreach ($section as $name => $val) {
if($key == "IFD0"){
echo "$key.$name: $val\n";
}
}
}
?>


And once you have identified the variable names that you wish to use, use something like;
<?php
$image = "image.jpg";
$exif = exif_read_data($image, 0, true);
echo "Latitude: " . $exif['IFD0']['Latitude'] . "\n";
?>


I've not tested this yet, but should be close? Let me know how you go!
Cheers,

Tim (toledoh.com.au)