Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions lib/Listener/ExifMetadataProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,18 @@ public function handle(Event $event): void {
// This is to trigger this condition: https://github.com/php/php-src/blob/d64aa6f646a7b5e58359dc79479860164239580a/main/streams/streams.c#L710
// But I don't understand yet why 1 as a special meaning.
$oldBufferSize = stream_set_chunk_size($fileDescriptor, 1);
if ($node->getMimeType() == 'image/webp') {
if ($node->getMimeType() === 'image/webp') {
$rawExifData = $this->getExifFromWebP($fileDescriptor);
} else {
}

$exifSupportedMimes = ['image/jpeg', 'image/tiff'];
if (in_array($node->getMimeType(), $exifSupportedMimes, true)) {
$rawExifData = @exif_read_data($fileDescriptor, 'EXIF, GPS', true);
}

// We then revert the change after having read the exif data.
stream_set_chunk_size($fileDescriptor, $oldBufferSize);
} catch (\Exception $ex) {
} catch (\Throwable $ex) {
$this->logger->info('Failed to extract metadata for ' . $node->getId(), ['exception' => $ex]);
}

Expand Down
Loading