fix: handle exif metadata read errors gracefully

Signed-off-by: Richard Steinmetz <richard@steinmetz.cloud>
This commit is contained in:
Richard Steinmetz 2024-01-15 09:12:49 +01:00
parent af003304c0
commit 84408cdc28
No known key found for this signature in database
GPG key ID: 27137D9E7D273FB2

View file

@ -67,8 +67,9 @@ class ExifProvider implements IMetadataProvider {
$size->setId($file->getId());
$size->setArrayAsValue([]);
if (!$data) {
$sizeResult = getimagesizefromstring($file->getContent());
$content = $file->getContent();
if (!$data && $content) {
$sizeResult = getimagesizefromstring($content);
if ($sizeResult !== false) {
$size->setArrayAsValue([
'width' => $sizeResult[0],
@ -77,7 +78,7 @@ class ExifProvider implements IMetadataProvider {
$exifData['size'] = $size;
}
} elseif (array_key_exists('COMPUTED', $data)) {
} elseif ($data && array_key_exists('COMPUTED', $data)) {
if (array_key_exists('Width', $data['COMPUTED']) && array_key_exists('Height', $data['COMPUTED'])) {
$size->setArrayAsValue([
'width' => $data['COMPUTED']['Width'],