Syntax adjustments #518
This commit is contained in:
parent
b9a7bd1056
commit
9e59062384
@ -789,40 +789,46 @@ final class Photo {
|
|||||||
// EXIF Metadata
|
// EXIF Metadata
|
||||||
if ($exif!==false) {
|
if ($exif!==false) {
|
||||||
|
|
||||||
|
// Orientation
|
||||||
if (isset($exif['Orientation'])) $return['orientation'] = $exif['Orientation'];
|
if (isset($exif['Orientation'])) $return['orientation'] = $exif['Orientation'];
|
||||||
else if (isset($exif['IFD0']['Orientation'])) $return['orientation'] = $exif['IFD0']['Orientation'];
|
else if (isset($exif['IFD0']['Orientation'])) $return['orientation'] = $exif['IFD0']['Orientation'];
|
||||||
|
|
||||||
|
// ISO
|
||||||
if (!empty($exif['ISOSpeedRatings'])) $return['iso'] = $exif['ISOSpeedRatings'];
|
if (!empty($exif['ISOSpeedRatings'])) $return['iso'] = $exif['ISOSpeedRatings'];
|
||||||
|
|
||||||
|
// Aperture
|
||||||
if (!empty($exif['COMPUTED']['ApertureFNumber'])) $return['aperture'] = $exif['COMPUTED']['ApertureFNumber'];
|
if (!empty($exif['COMPUTED']['ApertureFNumber'])) $return['aperture'] = $exif['COMPUTED']['ApertureFNumber'];
|
||||||
|
|
||||||
|
// Make
|
||||||
if (!empty($exif['Make'])) $return['make'] = trim($exif['Make']);
|
if (!empty($exif['Make'])) $return['make'] = trim($exif['Make']);
|
||||||
|
|
||||||
|
// Model
|
||||||
if (!empty($exif['Model'])) $return['model'] = trim($exif['Model']);
|
if (!empty($exif['Model'])) $return['model'] = trim($exif['Model']);
|
||||||
|
|
||||||
|
// Exposure
|
||||||
if (!empty($exif['ExposureTime'])) $return['shutter'] = $exif['ExposureTime'] . ' s';
|
if (!empty($exif['ExposureTime'])) $return['shutter'] = $exif['ExposureTime'] . ' s';
|
||||||
|
|
||||||
|
// Focal Length
|
||||||
if (!empty($exif['FocalLength'])) {
|
if (!empty($exif['FocalLength'])) {
|
||||||
if (strpos($exif['FocalLength'], '/')!==false) {
|
if (strpos($exif['FocalLength'], '/')!==false) {
|
||||||
$temp = explode('/', $exif['FocalLength'], 2);
|
$temp = explode('/', $exif['FocalLength'], 2);
|
||||||
$temp = $temp[0] / $temp[1];
|
$temp = $temp[0] / $temp[1];
|
||||||
$temp = round($temp, 1);
|
$temp = round($temp, 1);
|
||||||
$return['focal'] = $temp . ' mm';
|
$return['focal'] = $temp . ' mm';
|
||||||
|
} else {
|
||||||
|
$return['focal'] = $exif['FocalLength'] . ' mm';
|
||||||
}
|
}
|
||||||
else $return['focal'] = $exif['FocalLength'] . ' mm';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Takestamp
|
||||||
if (!empty($exif['DateTimeOriginal'])) $return['takestamp'] = strtotime($exif['DateTimeOriginal']);
|
if (!empty($exif['DateTimeOriginal'])) $return['takestamp'] = strtotime($exif['DateTimeOriginal']);
|
||||||
|
|
||||||
// Lens field from Lightroom
|
// Lens field from Lightroom
|
||||||
if (!empty($exif['UndefinedTag:0xA434'])) $return['lens'] = trim($exif['UndefinedTag:0xA434']);
|
if (!empty($exif['UndefinedTag:0xA434'])) $return['lens'] = trim($exif['UndefinedTag:0xA434']);
|
||||||
|
|
||||||
|
|
||||||
// Deal with GPS coordinates
|
// Deal with GPS coordinates
|
||||||
if (!empty($exif['GPSLatitude']) && !empty($exif['GPSLatitudeRef']))
|
if (!empty($exif['GPSLatitude']) && !empty($exif['GPSLatitudeRef'])) $return['latitude'] = getGPSCoordinate($exif['GPSLatitude'], $exif['GPSLatitudeRef']);
|
||||||
$return['latitude'] = getGPSCoordinate($exif['GPSLatitude'], $exif['GPSLatitudeRef']);
|
if (!empty($exif['GPSLongitude']) && !empty($exif['GPSLongitudeRef'])) $return['longitude'] = getGPSCoordinate($exif['GPSLongitude'], $exif['GPSLongitudeRef']);
|
||||||
if (!empty($exif['GPSLongitude']) && !empty($exif['GPSLongitudeRef']))
|
|
||||||
$return['longitude'] = getGPSCoordinate($exif['GPSLongitude'], $exif['GPSLongitudeRef']);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,24 +5,26 @@
|
|||||||
* @return string Normalized coordinate as float number (degrees).
|
* @return string Normalized coordinate as float number (degrees).
|
||||||
*/
|
*/
|
||||||
function getGPSCoordinate($coordinate, $ref) {
|
function getGPSCoordinate($coordinate, $ref) {
|
||||||
|
|
||||||
$degrees = count($coordinate) > 0 ? formattedToFloatGPS($coordinate[0]) : 0;
|
$degrees = count($coordinate) > 0 ? formattedToFloatGPS($coordinate[0]) : 0;
|
||||||
$minutes = count($coordinate) > 1 ? formattedToFloatGPS($coordinate[1]) : 0;
|
$minutes = count($coordinate) > 1 ? formattedToFloatGPS($coordinate[1]) : 0;
|
||||||
$seconds = count($coordinate) > 2 ? formattedToFloatGPS($coordinate[2]) : 0;
|
$seconds = count($coordinate) > 2 ? formattedToFloatGPS($coordinate[2]) : 0;
|
||||||
|
|
||||||
$flip = ($ref == 'W' || $ref == 'S') ? -1 : 1;
|
$flip = ($ref == 'W' || $ref == 'S') ? -1 : 1;
|
||||||
|
|
||||||
|
return $flip * ($degrees + (float)$minutes / 60 + (float)$seconds / 3600);
|
||||||
|
|
||||||
return $flip * ($degrees + (float)$minutes / 60 + (float)$seconds / 3600);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function formattedToFloatGPS($coordinate) {
|
function formattedToFloatGPS($coordinate) {
|
||||||
|
|
||||||
$parts = explode('/', $coordinate, 2);
|
$parts = explode('/', $coordinate, 2);
|
||||||
|
|
||||||
if (count($parts) <= 0)
|
if (count($parts) <= 0) return 0;
|
||||||
return 0;
|
if (count($parts) == 1) return $parts[0];
|
||||||
if (count($parts) == 1)
|
|
||||||
return $parts[0];
|
return (float)$parts[0] / $parts[1];
|
||||||
|
|
||||||
return (float)$parts[0] / $parts[1];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
Loading…
Reference in New Issue
Block a user