]> _ Git - cubist_util.git/commitdiff
#7704 @1
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 27 Aug 2025 15:04:56 +0000 (17:04 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 27 Aug 2025 15:04:56 +0000 (17:04 +0200)
src/CommandLine/Poppler.php

index 2350564f012ecdbc70f7bb83a1382f013acccbe3..b5cfa0147ad82818bcaec6331c7ab7a4af9f2ac5 100644 (file)
@@ -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);