From 0c1fb039145c824147fbd587edc9332d82c1ac4b Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 6 Jun 2010 21:01:36 -0700 Subject: Updated to Exifer --- modules/exif/lib/makers/gps.php | 128 +++++++++++++++------------------------- 1 file changed, 48 insertions(+), 80 deletions(-) (limited to 'modules/exif/lib/makers/gps.php') diff --git a/modules/exif/lib/makers/gps.php b/modules/exif/lib/makers/gps.php index 9a6ab137..462aae68 100644 --- a/modules/exif/lib/makers/gps.php +++ b/modules/exif/lib/makers/gps.php @@ -72,103 +72,66 @@ function lookup_GPS_tag($tag) { return $tag; } -//================= -// Formats a rational number -//==================================================================== -function GPSRational($data, $intel) { - - if($intel==1) $top = hexdec(substr($data,8,8)); //intel stores them bottom-top - else $top = hexdec(substr($data,0,8)); //motorola stores them top-bottom - - if($intel==1) $bottom = hexdec(substr($data,0,8)); //intel stores them bottom-top - else $bottom = hexdec(substr($data,8,8)); //motorola stores them top-bottom - - if($bottom!=0) $data=$top/$bottom; - else if($top==0) $data = 0; - else $data=$top."/".$bottom; - - return $data; -} //================= // Formats Data for the data type //==================================================================== function formatGPSData($type,$tag,$intel,$data) { if($type=="ASCII") { - if($tag=="0001" || $tag=="0003"){ // Latitude Reference, Longitude Reference - $data = ($data{1} == $data{2} && $data{1} == $data{3}) ? $data{0} : $data; - } - + if($tag=="0001" || $tag=="0003"){ // Latitude Reference, Longitude Reference + $data = ($data{1} == $data{2} && $data{1} == $data{3}) ? $data{0} : $data; + } + } else if($type=="URATIONAL" || $type=="SRATIONAL") { - $data = bin2hex($data); - if($intel==1) $data = intel2Moto($data); - - if($intel==1) $top = hexdec(substr($data,8,8)); //intel stores them bottom-top - else $top = hexdec(substr($data,0,8)); //motorola stores them top-bottom - - if($intel==1) $bottom = hexdec(substr($data,0,8)); //intel stores them bottom-top - else $bottom = hexdec(substr($data,8,8)); //motorola stores them top-bottom - - if($type=="SRATIONAL" && $top>2147483647) $top = $top - 4294967296; //this makes the number signed instead of unsigned - - if($tag=="0002" || $tag=="0004") { //Latitude, Longitude - - if($intel==1){ - $seconds = GPSRational(substr($data,0,16),$intel); - $hour = GPSRational(substr($data,32,16),$intel); - } else { - $hour= GPSRational(substr($data,0,16),$intel); - $seconds = GPSRational(substr($data,32,16),$intel); + if($tag=="0002" || $tag=="0004" || $tag=='0007') { //Latitude, Longitude, Time + $datum = array(); + for ($i=0;$i 1024) { $result['Errors'] = $result['Errors']++; + $data = ''; + $type = 'ASCII'; + } else { + $value = bin2hex($value); + if($intel==1) $value = intel2Moto($value); + $v = fseek($seek,$globalOffset+hexdec($value)); //offsets are from TIFF header which is 12 bytes from the start of the file + if($v==0) { + $data = fread($seek, $bytesofdata); + } else { + $result['Errors'] = $result['Errors']++; + $data = ''; + $type = 'ASCII'; + } } } - if($result['VerboseOutput']==1) { $result['GPS'][$tag_name] = formatGPSData($type,$tag,$intel,$data); $result['GPS'][$tag_name."_Verbose"]['RawData'] = bin2hex($data); -- cgit v1.2.3