From 571ff3ea74c7986324b4fff3a4121d506351059c Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Wed, 27 Aug 2025 17:04:56 +0200 Subject: [PATCH] #7704 @1 --- src/CommandLine/Poppler.php | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/CommandLine/Poppler.php b/src/CommandLine/Poppler.php index 2350564..b5cfa01 100644 --- a/src/CommandLine/Poppler.php +++ b/src/CommandLine/Poppler.php @@ -14,15 +14,8 @@ class Poppler const RESOLUTION_FACTOR = 72; - /** - * @throws \Exception - */ - public static function extractArea($file, $page, $rect, $to = null, $options = array(), $cache = null) + protected static function _normalizeExtractAreaOptions($options) { - if (null === $to && null === $cache) { - throw new \Exception('You have to define either a destination file or a cache folder'); - } - $defaultOptions = array('resolution' => 300, 'quality' => '95', 'antialias' => true, @@ -34,6 +27,20 @@ class Poppler $options = array_merge($defaultOptions, $options); $options['factor'] = $options['resolution'] / self::RESOLUTION_FACTOR; + return $options; + } + + + /** + * @throws \Exception + */ + public static function extractArea($file, $page, $rect, $to = null, $options = array(), $cache = null) + { + if (null === $to && null === $cache) { + throw new \Exception('You have to define either a destination file or a cache folder'); + } + + $options = self::_normalizeExtractAreaOptions($options); $extension = self::_format2ext($options['format']); if (null !== $to) { @@ -113,6 +120,7 @@ class Poppler public static function extractAreaFilehash($file, $page, $rect, $options): string { + $f = Files::hashFileAttributes($file) . '||' . '++' . json_encode($rect) . '**' . json_encode($options) . '||' . $page . '!!'; $hash = hash('sha256', $f); error_log($f . '//' . $hash); -- 2.39.5