From ce4748abe26c8f887e0dab1746adff2f57354f9b Mon Sep 17 00:00:00 2001 From: Michele Locati Date: Tue, 30 Jul 2024 16:56:13 +0200 Subject: [PATCH] Exif reader: avoid converting stream to string to stream (#862) --- src/Image/Metadata/AbstractMetadataReader.php | 4 ++-- src/Image/Metadata/ExifMetadataReader.php | 2 +- src/Image/Metadata/MetadataReaderInterface.php | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Image/Metadata/AbstractMetadataReader.php b/src/Image/Metadata/AbstractMetadataReader.php index 059399625..26a55789a 100644 --- a/src/Image/Metadata/AbstractMetadataReader.php +++ b/src/Image/Metadata/AbstractMetadataReader.php @@ -100,7 +100,7 @@ abstract protected function extractFromFile($file); /** * Extracts metadata from raw data. * - * @param $data + * @param string $data * * @return array An associative array of metadata */ @@ -109,7 +109,7 @@ abstract protected function extractFromData($data); /** * Extracts metadata from a stream. * - * @param $resource + * @param resource $resource * * @return array An associative array of metadata */ diff --git a/src/Image/Metadata/ExifMetadataReader.php b/src/Image/Metadata/ExifMetadataReader.php index b5bf3c46a..2d911f35d 100644 --- a/src/Image/Metadata/ExifMetadataReader.php +++ b/src/Image/Metadata/ExifMetadataReader.php @@ -98,7 +98,7 @@ protected function extractFromData($data) */ protected function extractFromStream($resource) { - return $this->doReadData(stream_get_contents($resource)); + return PHP_VERSION_ID < 70200 ? $this->doReadData(stream_get_contents($resource)) : $this->extract($resource); } /** diff --git a/src/Image/Metadata/MetadataReaderInterface.php b/src/Image/Metadata/MetadataReaderInterface.php index 6d4ea5ada..302cd660f 100644 --- a/src/Image/Metadata/MetadataReaderInterface.php +++ b/src/Image/Metadata/MetadataReaderInterface.php @@ -31,7 +31,7 @@ public function readFile($file); * Reads metadata from a binary string. * * @param string $data the binary string to read - * @param resource $originalResource an optional resource to gather stream metadata + * @param resource|null $originalResource an optional resource to gather stream metadata * * @return \Imagine\Image\Metadata\MetadataBag */