Skip to content

Commit

Permalink
fix: handle exif metadata read errors gracefully
Browse files Browse the repository at this point in the history
Signed-off-by: Richard Steinmetz <richard@steinmetz.cloud>
  • Loading branch information
st3iny committed Jan 15, 2024
1 parent baf49e3 commit 94d7e45
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/private/Metadata/Provider/ExifProvider.php
Expand Up @@ -71,8 +71,9 @@ public function execute(File $file): array {
$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],
Expand All @@ -81,7 +82,7 @@ public function execute(File $file): array {

$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'],
Expand Down

0 comments on commit 94d7e45

Please sign in to comment.