Merge branch 'AndreAle94-master'
commit
e9f2fb91d4
10
lib/Exif.php
10
lib/Exif.php
|
@ -180,25 +180,17 @@ class Exif
|
||||||
*/
|
*/
|
||||||
public static function getDateTaken(File &$file, array &$exif)
|
public static function getDateTaken(File &$file, array &$exif)
|
||||||
{
|
{
|
||||||
|
// Try to parse the date from exif metadata
|
||||||
$dt = $exif['DateTimeOriginal'] ?? null;
|
$dt = $exif['DateTimeOriginal'] ?? null;
|
||||||
if (!isset($dt) || empty($dt)) {
|
|
||||||
$dt = $exif['CreateDate'] ?? null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if found something
|
|
||||||
try {
|
try {
|
||||||
return self::parseExifDate($dt);
|
return self::parseExifDate($dt);
|
||||||
} catch (\Exception $ex) {
|
} catch (\Exception $ex) {
|
||||||
} catch (\ValueError $ex) {
|
} catch (\ValueError $ex) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fall back to creation time
|
|
||||||
$dateTaken = $file->getCreationTime();
|
|
||||||
|
|
||||||
// Fall back to modification time
|
// Fall back to modification time
|
||||||
if (0 === $dateTaken) {
|
|
||||||
$dateTaken = $file->getMtime();
|
$dateTaken = $file->getMtime();
|
||||||
}
|
|
||||||
|
|
||||||
return self::forgetTimezone($dateTaken);
|
return self::forgetTimezone($dateTaken);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue