i am trying to get lat, long numbers from images that have geo tags using
exif_read_data();
i found this code and people say that it works well but its producing errors for me
Code:
Undefined index: GPSLongitude
Undefined index: GPSLongitudeRef
Undefined index: GPSLatitude
Undefined index: GPSLatitudeRef
Code:
function getGps($exifCoord, $hemi) {
$degrees = count($exifCoord) > 0 ? gps2Num($exifCoord[0]) : 0;
$minutes = count($exifCoord) > 1 ? gps2Num($exifCoord[1]) : 0;
$seconds = count($exifCoord) > 2 ? gps2Num($exifCoord[2]) : 0;
$flip = ($hemi == 'W' or $hemi == 'S') ? -1 : 1;
return $flip * ($degrees + $minutes / 60 + $seconds / 3600);
}
function gps2Num($coordPart) {
$parts = explode('/', $coordPart);
if (count($parts) <= 0)
return 0;
if (count($parts) == 1)
return $parts[0];
return floatval($parts[0]) / floatval($parts[1]);
}
$filename = "IMG_1406.jpeg";
$exif = exif_read_data($filename, 'IDF0');
$lon = getGps($exif["GPSLongitude"], $exif['GPSLongitudeRef']);
$lat = getGps($exif["GPSLatitude"], $exif['GPSLatitudeRef']);
var_dump($lat, $lon);
also, i made sure in my php.ini
extension=php_mbstring.dll
extension=php_exif.dll
and not:
extension=php_exif.dll
extension=php_mbstring.dll
any suggestions on how to get this to work please
thank you
re: just found out that it was the jpg
images with geo tag will output lat/long coordinates correctly
Bookmarks