2147483647) $top = $top - 4294967296; //this makes the number signed instead of unsigned if($tag=="0002" || $tag=="0004") { //Latitude $seconds = GPSRational(substr($data,0,16),$intel); $minutes = GPSRational(substr($data,16,16),$intel); $hour = GPSRational(substr($data,32,16),$intel); $data = $hour+$minutes/60+$seconds/3600; } else if($tag=="0007") { //Time $seconds = GPSRational(substr($data,0,16),$intel); $minutes = GPSRational(substr($data,16,16),$intel); $hour = GPSRational(substr($data,32,16),$intel); $data = $hour.":".$minutes.":".$seconds; } else { if($bottom!=0) $data=$top/$bottom; else if($top==0) $data = 0; else $data=$top."/".$bottom; } } else if($type=="USHORT" || $type=="SSHORT" || $type=="ULONG" || $type=="SLONG" || $type=="FLOAT" || $type=="DOUBLE") { $data = bin2hex($data); if($intel==1) $data = intel2Moto($data); $data=hexdec($data); } else if($type=="UNDEFINED") { } else if($type=="UBYTE") { $data = bin2hex($data); if($intel==1) $num = intel2Moto($data); if($tag=="0000") { //Latitude $data = hexdec(substr($data,0,2)).".". hexdec(substr($data,2,2)).".". hexdec(substr($data,4,2)).".". hexdec(substr($data,6,2)); } } else { $data = bin2hex($data); if($intel==1) $data = intel2Moto($data); } return $data; } //================= // GPS Special data section // Useful websites // http://drewnoakes.com/code/exif/sampleOutput.html // http://www.geosnapper.com //==================================================================== function parseGPS($block,&$result,$offset,$seek, $globalOffset) { if($result['Endien']=="Intel") $intel=1; else $intel=0; $v = fseek($seek,$globalOffset+$offset); //offsets are from TIFF header which is 12 bytes from the start of the file if($v==-1) { $result['Errors'] = $result['Errors']++; } $num = bin2hex(fread( $seek, 2 )); if($intel==1) $num = intel2Moto($num); $num=hexdec($num); $result['GPS']['NumTags'] = $num; $block = fread( $seek, $num*12 ); $place = 0; //loop thru all tags Each field is 12 bytes for($i=0;$i<$num;$i++) { //2 byte tag $tag = bin2hex(substr($block,$place,2));$place+=2; if($intel==1) $tag = intel2Moto($tag); $tag_name = lookup_GPS_tag($tag); //2 byte datatype $type = bin2hex(substr($block,$place,2));$place+=2; if($intel==1) $type = intel2Moto($type); lookup_type($type,$size); //4 byte number of elements $count = bin2hex(substr($block,$place,4));$place+=4; if($intel==1) $count = intel2Moto($count); $bytesofdata = $size*hexdec($count); //4 byte value or pointer to value if larger than 4 bytes $value = substr($block,$place,4);$place+=4; if($bytesofdata<=4) { $data = $value; } 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 if($v==-1) { $result['Errors'] = $result['Errors']++; } } if($result['VerboseOutput']==1) { $result['GPS'][$tag_name] = formatGPSData($type,$tag,$intel,$data); $result['GPS'][$tag_name."_Verbose"]['RawData'] = bin2hex($data); $result['GPS'][$tag_name."_Verbose"]['Type'] = $type; $result['GPS'][$tag_name."_Verbose"]['Bytes'] = $bytesofdata; } else { $result['GPS'][$tag_name] = formatGPSData($type,$tag,$intel,$data); } } } ?>