|
@@ -307,7 +307,7 @@ final class Photo {
|
|
$newUrl2x = LYCHEE_UPLOADS_THUMB . $photoName[0] . '@2x.jpeg';
|
|
$newUrl2x = LYCHEE_UPLOADS_THUMB . $photoName[0] . '@2x.jpeg';
|
|
|
|
|
|
// Create thumbnails with Imagick
|
|
// Create thumbnails with Imagick
|
|
- if(extension_loaded('imagick')&&Settings::get()['imagick']==='1') {
|
|
|
|
|
|
+ if(Settings::hasImagick()) {
|
|
|
|
|
|
// Read image
|
|
// Read image
|
|
$thumb = new Imagick();
|
|
$thumb = new Imagick();
|
|
@@ -727,48 +727,61 @@ final class Photo {
|
|
$info = getimagesize($url, $iptcArray);
|
|
$info = getimagesize($url, $iptcArray);
|
|
|
|
|
|
// General information
|
|
// General information
|
|
- $return['type'] = $info['mime'];
|
|
|
|
- $return['width'] = $info[0];
|
|
|
|
- $return['height'] = $info[1];
|
|
|
|
|
|
+ $return['type'] = $info['mime'];
|
|
|
|
+ $return['width'] = $info[0];
|
|
|
|
+ $return['height'] = $info[1];
|
|
|
|
+ $return['title'] = '';
|
|
|
|
+ $return['description'] = '';
|
|
|
|
+ $return['orientation'] = '';
|
|
|
|
+ $return['iso'] = '';
|
|
|
|
+ $return['aperture'] = '';
|
|
|
|
+ $return['make'] = '';
|
|
|
|
+ $return['model'] = '';
|
|
|
|
+ $return['shutter'] = '';
|
|
|
|
+ $return['focal'] = '';
|
|
|
|
+ $return['takestamp'] = 0;
|
|
|
|
+ $return['lens'] = '';
|
|
|
|
+ $return['tags'] = array();
|
|
|
|
+ $return['position'] = '';
|
|
|
|
+ $return['latitude'] = '';
|
|
|
|
+ $return['longitude'] = '';
|
|
|
|
+ $return['altitude'] = '';
|
|
|
|
|
|
// Size
|
|
// Size
|
|
$size = filesize($url)/1024;
|
|
$size = filesize($url)/1024;
|
|
if ($size>=1024) $return['size'] = round($size/1024, 1) . ' MB';
|
|
if ($size>=1024) $return['size'] = round($size/1024, 1) . ' MB';
|
|
else $return['size'] = round($size, 1) . ' KB';
|
|
else $return['size'] = round($size, 1) . ' KB';
|
|
|
|
|
|
- // IPTC Metadata Fallback
|
|
|
|
- $return['title'] = '';
|
|
|
|
- $return['description'] = '';
|
|
|
|
-
|
|
|
|
// IPTC Metadata
|
|
// IPTC Metadata
|
|
|
|
+ // See https://www.iptc.org/std/IIM/4.2/specification/IIMV4.2.pdf for mapping
|
|
if(isset($iptcArray['APP13'])) {
|
|
if(isset($iptcArray['APP13'])) {
|
|
|
|
|
|
$iptcInfo = iptcparse($iptcArray['APP13']);
|
|
$iptcInfo = iptcparse($iptcArray['APP13']);
|
|
if (is_array($iptcInfo)) {
|
|
if (is_array($iptcInfo)) {
|
|
|
|
|
|
- $temp = @$iptcInfo['2#105'][0];
|
|
|
|
- if (isset($temp)&&strlen($temp)>0) $return['title'] = $temp;
|
|
|
|
|
|
+ // Title
|
|
|
|
+ if (!empty($iptcInfo['2#105'][0])) $return['title'] = $iptcInfo['2#105'][0];
|
|
|
|
+ else if (!empty($iptcInfo['2#005'][0])) $return['title'] = $iptcInfo['2#005'][0];
|
|
|
|
+
|
|
|
|
+ // Description
|
|
|
|
+ if (!empty($iptcInfo['2#120'][0])) $return['description'] = $iptcInfo['2#120'][0];
|
|
|
|
|
|
- $temp = @$iptcInfo['2#120'][0];
|
|
|
|
- if (isset($temp)&&strlen($temp)>0) $return['description'] = $temp;
|
|
|
|
|
|
+ // Tags
|
|
|
|
+ if (!empty($iptcInfo['2#025'])) $return['tags'] = $iptcInfo['2#025'];
|
|
|
|
|
|
- $temp = @$iptcInfo['2#005'][0];
|
|
|
|
- if (isset($temp)&&strlen($temp)>0&&$return['title']==='') $return['title'] = $temp;
|
|
|
|
|
|
+ // Position
|
|
|
|
+ $fields = array();
|
|
|
|
+ if (!empty($iptcInfo['2#090'])) $fields[] = trim($iptcInfo['2#090']);
|
|
|
|
+ if (!empty($iptcInfo['2#092'])) $fields[] = trim($iptcInfo['2#092']);
|
|
|
|
+ if (!empty($iptcInfo['2#095'])) $fields[] = trim($iptcInfo['2#095']);
|
|
|
|
+ if (!empty($iptcInfo['2#101'])) $fields[] = trim($iptcInfo['2#101']);
|
|
|
|
+
|
|
|
|
+ if (!empty($fields)) $return['position'] = implode(', ', $fields);
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- // EXIF Metadata Fallback
|
|
|
|
- $return['orientation'] = '';
|
|
|
|
- $return['iso'] = '';
|
|
|
|
- $return['aperture'] = '';
|
|
|
|
- $return['make'] = '';
|
|
|
|
- $return['model'] = '';
|
|
|
|
- $return['shutter'] = '';
|
|
|
|
- $return['focal'] = '';
|
|
|
|
- $return['takestamp'] = 0;
|
|
|
|
-
|
|
|
|
// Read EXIF
|
|
// Read EXIF
|
|
if ($info['mime']=='image/jpeg') $exif = @exif_read_data($url, 'EXIF', 0);
|
|
if ($info['mime']=='image/jpeg') $exif = @exif_read_data($url, 'EXIF', 0);
|
|
else $exif = false;
|
|
else $exif = false;
|
|
@@ -779,24 +792,19 @@ final class Photo {
|
|
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'];
|
|
|
|
|
|
- $temp = @$exif['ISOSpeedRatings'];
|
|
|
|
- if (isset($temp)) $return['iso'] = $temp;
|
|
|
|
|
|
+ if (!empty($exif['ISOSpeedRatings'])) $return['iso'] = $exif['ISOSpeedRatings'];
|
|
|
|
|
|
- $temp = @$exif['COMPUTED']['ApertureFNumber'];
|
|
|
|
- if (isset($temp)) $return['aperture'] = $temp;
|
|
|
|
|
|
+ if (!empty($exif['COMPUTED']['ApertureFNumber'])) $return['aperture'] = $exif['COMPUTED']['ApertureFNumber'];
|
|
|
|
|
|
- $temp = @$exif['Make'];
|
|
|
|
- if (isset($temp)) $return['make'] = trim($temp);
|
|
|
|
|
|
+ if (!empty($exif['Make'])) $return['make'] = trim($exif['Make']);
|
|
|
|
|
|
- $temp = @$exif['Model'];
|
|
|
|
- if (isset($temp)) $return['model'] = trim($temp);
|
|
|
|
|
|
+ if (!empty($exif['Model'])) $return['model'] = trim($exif['Model']);
|
|
|
|
|
|
- $temp = @$exif['ExposureTime'];
|
|
|
|
- if (isset($temp)) $return['shutter'] = $exif['ExposureTime'] . ' s';
|
|
|
|
|
|
+ if (!empty($exif['ExposureTime'])) $return['shutter'] = $exif['ExposureTime'] . ' s';
|
|
|
|
|
|
$temp = @$exif['FocalLength'];
|
|
$temp = @$exif['FocalLength'];
|
|
if (isset($temp)) {
|
|
if (isset($temp)) {
|
|
- if (strpos($temp, '/')!==FALSE) {
|
|
|
|
|
|
+ if (strpos($temp, '/')!==false) {
|
|
$temp = explode('/', $temp, 2);
|
|
$temp = explode('/', $temp, 2);
|
|
$temp = $temp[0] / $temp[1];
|
|
$temp = $temp[0] / $temp[1];
|
|
$temp = round($temp, 1);
|
|
$temp = round($temp, 1);
|
|
@@ -805,8 +813,14 @@ final class Photo {
|
|
$return['focal'] = $temp . ' mm';
|
|
$return['focal'] = $temp . ' mm';
|
|
}
|
|
}
|
|
|
|
|
|
- $temp = @$exif['DateTimeOriginal'];
|
|
|
|
- if (isset($temp)) $return['takestamp'] = strtotime($temp);
|
|
|
|
|
|
+ if (!empty($exif['DateTimeOriginal'])) $return['takestamp'] = strtotime($exif['DateTimeOriginal']);
|
|
|
|
+
|
|
|
|
+ // Lens field from Lightroom
|
|
|
|
+ if (!empty($exif['UndefinedTag:0xA434'])) $return['lens'] = trim($exif['UndefinedTag:0xA434']);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ $return['latitude'] = '';
|
|
|
|
+ $return['longitude'] = '';
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|