Changeset 25801 for trunk/include/functions_metadata.inc.php
- Timestamp:
- Dec 6, 2013, 8:14:44 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/functions_metadata.inc.php
r25550 r25801 153 153 if ($exif = @read_exif_data($filename)) 154 154 { 155 $exif = trigger_event('format_exif_data', $exif, $filename, $map ); 155 $exif = trigger_event('format_exif_data', $exif, $filename, $map); 156 157 // configured fields 156 158 foreach ($map as $key => $field) 157 159 { … … 170 172 $result[$key] = $exif[$tokens[0]][$tokens[1]]; 171 173 } 174 } 175 } 176 177 // GPS data 178 $gps_exif = array_intersect_key($exif, array_flip(array('GPSLatitudeRef', 'GPSLatitude', 'GPSLongitudeRef', 'GPSLongitude'))); 179 if (count($gps_exif) == 4) 180 { 181 if ( 182 is_array($gps_exif['GPSLatitude']) and in_array($gps_exif['GPSLatitudeRef'], array('S', 'N')) and 183 is_array($gps_exif['GPSLongitude']) and in_array($gps_exif['GPSLongitudeRef'], array('W', 'E')) 184 ) 185 { 186 $result['latitude'] = parse_exif_gps_data($gps_exif['GPSLatitude'], $gps_exif['GPSLatitudeRef']); 187 $result['longitude'] = parse_exif_gps_data($gps_exif['GPSLongitude'], $gps_exif['GPSLongitudeRef']); 172 188 } 173 189 } … … 187 203 } 188 204 205 206 /** 207 * Converts EXIF GPS format to a float value. 208 * @since 2.6 209 * 210 * @param string[] $raw eg: 211 * - 41/1 212 * - 54/1 213 * - 9843/500 214 * @param string $ref 'S', 'N', 'E', 'W'. eg: 'N' 215 * @return float eg: 41.905468 216 */ 217 function parse_exif_gps_data($raw, $ref) 218 { 219 foreach ($raw as &$i) 220 { 221 $i = explode('/', $i); 222 $i = $i[1]==0 ? 0 : $i[0]/$i[1]; 223 } 224 unset($i); 225 226 $v = $raw[0] + $raw[1]/60 + $raw[2]/3600; 227 228 $ref = strtoupper($ref); 229 if ($ref == 'S' or $ref == 'W') $v= -$v; 230 231 return $v; 232 } 233 189 234 ?>
Note: See TracChangeset
for help on using the changeset viewer.