我想从桌面上的图片中获取纬度和经度信息。我谷歌搜索非常想知道如何获取这些信息。我还在努力...... 如果有人对此有所了解...那么请指导我..如果可能的话,提供任何解决方案..
答案 0 :(得分:1)
首先要确保使用EXif:
<?php
echo "test1.jpg:<br />\n";
$exif = exif_read_data('tests/test1.jpg', 'IFD0');
echo $exif===false ? "No header data found.<br />\n" : "Image contains headers<br />\n";
$exif = exif_read_data('tests/test2.jpg', 0, true);
echo "test2.jpg:<br />\n";
foreach ($exif as $key => $section) {
foreach ($section as $name => $val) {
echo "$key.$name: $val<br />\n";
}
}
?>
然后
<?php
$image_file = 'D:\Photoes\2011\IMG_0712.jpg';
if(file_exists($image_file)){
$details = exif_read_data($image_file);
$sections = explode(',',$details['SectionsFound']);
if(in_array('GPS',array_flip($sections))){
echo format_gps_data($details['GPSLatitude'],$details['GPSLatitudeRef']);
echo '<br/>';
echo format_gps_data($details['GPSLongitude'],$details['GPSLongitudeRef']);
}else{
die('GPS data not found');
}
}else{
die('File does not exists');
}
function format_gps_data($gpsdata,$lat_lon_ref){
$gps_info = array();
foreach($gpsdata as $gps){
list($j , $k) = explode('/', $gps);
array_push($gps_info,$j/$k);
}
$coordination = $gps_info[0] + ($gps_info[1]/60.00) + ($gps_info[2]/3600.00);
return (($lat_lon_ref == "S" || $lat_lon_ref == "W" ) ? '-'.$coordination : $coordination).' '.$lat_lon_ref;
}
?>
然后看看这个: Good Work With GPS INFO