« on: 24, 10, 2011, 11:23:28 »
<?php
$exif_data = exif_read_data('images/photofromiphone.jpg');
function defraction( $fraction )
{
list( $nominator, $denominator ) = explode( "/", $fraction );
if( $denominator )
{
return ( $nominator / $denominator );
}
else
{
return $fraction;
}
}
// Get the exif data
// Latitude
$northing = -1;
if( $exif_data['GPSLatitudeRef'] && 'N' == $exif_data['GPSLatitudeRef'] )
{
$northing = 1;
}
$northing *= defraction( $exif_data['GPSLatitude'][0] ) + ( defraction($exif_data['GPSLatitude'][1] ) / 60 ) + ( defraction( $exif_data['GPSLatitude'][2] ) / 3600 );
// Longitude
$easting = -1;
if( $exif_data['GPSLongitudeRef'] && 'E' == $exif_data['GPSLongitudeRef'] )
{
$easting = 1;
}
$easting *= defraction( $exif_data['GPSLongitude'][0] ) + ( defraction( $exif_data['GPSLongitude'][1] ) / 60 ) + ( defraction( $exif_data['GPSLongitude'][2] ) / 3600 );
echo"<h1>lat :".$northing."</h1>";
echo"<h1>lng :".$easting."</h1>";
?>
ที่มา
http://stackoverflow.com/questions/2526304/php-extract-gps-exif-data
« Last Edit: 24, 10, 2011, 13:55:31 by aegkaluk »

Logged