Thursday, January 24, 2013

php: extract image coordinates via exif

configure php with '--enable-exif' 

extract coordinates from exif

<?php
        $file = $_GET['file'];
        $exif = exif_read_data($file, 0, true);
 
        if(!$exif || $exif['GPS']['GPSLongitude'] == '')
        {
                $response = '';
        }
        else
        {
                $long = $exif['GPS']['GPSLongitude'];
                list($num, $dec) = explode('/',$long[0]);
                $long_d = $num / $dec;
                list($num, $dec) = explode('/',$long[1]);
                $long_m = $num / $dec;
                list($num, $dec) = explode('/',$long[2]);
                $long_s = $num / $dec;
                $long_dec = $long_d + $long_m / 60 + $long_s / 3600;
 
                $lat = $exif['GPS']['GPSLatitude'];
                list($num, $dec) = explode('/',$lat[0]);
                $lat_d = $num / $dec;
                list($num, $dec) = explode('/',$lat[1]);
                $lat_m = $num / $dec;
                list($num, $dec) = explode('/',$lat[2]);
                $lat_s = $num / $dec;
                $lat_dec = $lat_d + $lat_m / 60 + $lat_s / 3600;
 
                $response = trim($long_dec . " " . $lat_dec);
        }
        echo $response;
?>

No comments:

Post a Comment

SSH : No matching host key type found. Their offer: ssh-rsa,ssh-dss

Got this while connecting to my mikrotik router via ssh   Unable to negotiate with <ip address> port <ssh port>: no matching hos...