From: Vincent Vanwaelscappel Date: Wed, 27 Aug 2025 15:04:56 +0000 (+0200) Subject: #7704 @1 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=571ff3ea74c7986324b4fff3a4121d506351059c;p=cubist_util.git #7704 @1 --- 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);