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,
$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) {
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);