diff --git a/src/Phpro/Filesystem/Metadata/Image/Identify.php b/src/Phpro/Filesystem/Metadata/Image/Identify.php index d7efbd4..f85020e 100644 --- a/src/Phpro/Filesystem/Metadata/Image/Identify.php +++ b/src/Phpro/Filesystem/Metadata/Image/Identify.php @@ -48,7 +48,11 @@ protected function parseIdentify(FileInterface $file, array $options = []) { try { $image = $this->imagick; - $image->readImage($file->getPath()); + + $format = strtolower(pathinfo($file->getPath(), PATHINFO_EXTENSION)); + $source = $this->alterSource($file->getPath(), $format); + + $image->readImage($source); $identifyData = $image->identifyImage(); if (isset($options['extended']) && $options['extended']) { @@ -76,4 +80,22 @@ protected function hasSpotColors(Imagick $image) return count($spotColors) ? true : false; } + + /** + * Makes it possible to change the source of a file based on the format. + * Only read/identify the first page of a PDF file. + * + * @param $source + * @param $format + * + * @return string + */ + protected function alterSource($source, $format) + { + if (strtolower($format) == 'pdf') { + return $source . '[0]'; + } + + return $source; + } }