From: vincent@cubedesigners.com Date: Thu, 30 Sep 2021 14:29:40 +0000 (+0000) Subject: wip #4726 @1.5 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=8b10ceaf5f2eac6d2e38155ff5db623b60b9f05b;p=cubeextranet.git wip #4726 @1.5 --- diff --git a/inc/ws/Metier/class.ws.book.parametres.php b/inc/ws/Metier/class.ws.book.parametres.php index bf283495d..7ff4d7276 100644 --- a/inc/ws/Metier/class.ws.book.parametres.php +++ b/inc/ws/Metier/class.ws.book.parametres.php @@ -290,13 +290,14 @@ class wsBookParametres extends wsParametres $this->fields['extraYSpace'] = array('type' => 'integer', 'default' => '0', 'editable' => true, 'label' => __('Marge supplémentaire verticale'), 'grade' => 3); $this->fields['centerBook'] = array('type' => 'boolean', 'default' => true, 'editable' => true, 'label' => __('Centrer la publication sur les couvertures'), 'grade' => 2); $this->fields['correctCenter'] = array('type' => 'boolean', 'default' => true, 'editable' => true, 'label' => __('Corriger les lignes blanches entre les pages'), 'grade' => 2); - $this->fields['maxResolution'] = array('type' => 'combo', 'default' => 300, 'editable' => true, 'datas' => array('300dpi' => 300, '150dpi' => 150), 'grade' => 2, 'label' => __('Résolution maximale des pages')); + $this->fields['maxResolution'] = array('type' => 'combo', 'default' => 300, 'editable' => true, 'datas' => array('300dpi' => 300, '150dpi' => 150, '125dpi' => 125, '100dpi' => 100), 'grade' => 2, 'label' => __('Résolution maximale des pages')); + $this->fields['JPEGQuality'] = array('type' => 'integer', 'default' => 85, 'editable' => true, 'grade' => 2, 'label' => __('Qualité JPEG')); $this->fields['imageFormat'] = array('type' => 'combo', 'default' => 'jpg', 'editable' => true, 'datas' => array(/*__('Le plus léger') => 'best', */ 'JPEG' => 'jpg', 'PNG' => 'png'), 'grade' => 2, 'label' => __('Format des images')); $this->fields['dynamicBackgroundColor'] = ['type' => 'textarea', 'default' => '', 'editable' => true, 'label' => 'Couleur de fond dynamique', 'grade' => 3]; $this->forms['3d_mode'] = array('label' => __('Options de visualisation'), - 'fieldsnames' => array('mobileNavigationType', '|', 'mobileTransitions', 'mobileTransitionDuration', '|', 'forceWhiteBackground', 'rasterizePages', 'vectorPages', 'visualisationMode', 'antialiasReading', 'correctCenter', 'pagesBaseAngle', 'centerBook', '|', 'extraXSpace', 'mobileExtraXSpace', 'extraYSpace', '|', 'viewMode', '|', 'dynamicBackgroundColor', '|', 'imageFormat', 'maxResolution')); + 'fieldsnames' => array('mobileNavigationType', '|', 'mobileTransitions', 'mobileTransitionDuration', '|', 'forceWhiteBackground', 'rasterizePages', 'vectorPages', 'visualisationMode', 'antialiasReading', 'correctCenter', 'pagesBaseAngle', 'centerBook', '|', 'extraXSpace', 'mobileExtraXSpace', 'extraYSpace', '|', 'viewMode', '|', 'dynamicBackgroundColor', '|', 'imageFormat', 'maxResolution', 'JPEGQuality')); $this->fields['rasterizeOnSafari'] = array('type' => 'boolean', 'default' => false, 'editable' => true, 'label' => __('Ecraser les pages pour Safari (Mac OS)'), 'grade' => 1); $this->forms['performances'] = ['label' => __('Performances'), diff --git a/inc/ws/Metier/class.ws.book.php b/inc/ws/Metier/class.ws.book.php index 68e9bf4f5..3749e6d98 100644 --- a/inc/ws/Metier/class.ws.book.php +++ b/inc/ws/Metier/class.ws.book.php @@ -92,6 +92,14 @@ class wsBook extends cubeMetier $dao = new wsDAODocument($core->con); $this->_docs[$p['document_id']] = $dao->selectById($p['document_id']); } + if ($format === 'jpg') { + $q = $this->parametres->JPEGQuality ?? 85; + } else { + $q = 85; + } + if ($q != 85) { + $resolution .= '-' . $q; + } $doc = $this->_docs[$p['document_id']]; return $doc->getFile($p['document_page'], $format, $resolution, $withText, $withGraphics, $version, $force); } diff --git a/inc/ws/Metier/class.ws.document.php b/inc/ws/Metier/class.ws.document.php index e50ef3b07..14ecf9932 100644 --- a/inc/ws/Metier/class.ws.document.php +++ b/inc/ws/Metier/class.ws.document.php @@ -496,11 +496,19 @@ class wsDocument extends cubeMetier $this->makeTextSVGFile($page, $file); } } else if ($format === 'png' || $format === 'jpg') { + $e = explode('-', $resolution); + if (count($e) > 1) { + $resolution = $e[0]; + $quality = $e[1]; + }else{ + $quality=85; + } + if ($resolution === 'thumb') { wsPDFConvert::makeMiniShot($this->getSplittedPDFPage($page), $file, 1, $format); } else { $rr = $version === 'html' ? $this->getResolutionRatio() : $this->getMobileFirstRatio(); - wsPDFConvert::makeShotPNM($this->getSplittedPDFPage($page), $file, 1, '', $resolution * $rr, 85, 4, $withText, null, null, $format); + wsPDFConvert::makeShotPNM($this->getSplittedPDFPage($page), $file, 1, '', $resolution * $rr, $quality, 4, $withText, null, null, $format); } } else if ($format === 'swf') { wsPDFConvert::makeSWF($this->getSplittedPDFPage($page), $file, 1, $resolution, 80); diff --git a/inc/ws/Util/html5/svgtocanvas/class.ws.html5.compiler.php b/inc/ws/Util/html5/svgtocanvas/class.ws.html5.compiler.php index 74d72502f..d64fd7db8 100644 --- a/inc/ws/Util/html5/svgtocanvas/class.ws.html5.compiler.php +++ b/inc/ws/Util/html5/svgtocanvas/class.ws.html5.compiler.php @@ -18,6 +18,8 @@ class wsHTML5Compiler 'js/libs/threejs/legacy/Projector.js', 'js/libs/threejs/legacy/CanvasRenderer.js', ], + 'canvg' => + ['js/libs/canvg/canvg.min.js'], // 'threejs-latest' => // ['js/libs/threejs/latest/three.min.js', // ], @@ -112,6 +114,7 @@ class wsHTML5Compiler 'js/libs/fluidbook/fluidbook.mobilefirst.js', 'js/libs/fluidbook/mobilefirst/fluidbook.mobilefirst.slider.js', ], + ]; public $specialJsFiles = array(); @@ -838,12 +841,13 @@ class wsHTML5Compiler public function getResolutions() { $res = []; - foreach (self::$resolutions as $r) { - if ($r > $this->maxRes) { - continue; - } - $res[] = $r; + + if ($this->maxRes == 300) { + $res = [150, 300]; + } else if ($this->maxRes <= 150) { + $res = [$this->maxRes]; } + if ($this->widget) { $res = array_merge(array(36), $res); } @@ -2282,7 +2286,7 @@ height="0" width="0" style="display:none;visibility:hidden"> foreach ($this->getResolutions() as $r) { foreach ($thisbackgroundPrefix as $backgroundsPrefix) { $source = $this->book->getFile($page, $this->imageFormat, $r, $backgroundsPrefix, true, $imdir); - if ($r == 150 && file_exists($source)) { + if ($r == $this->maxRes && file_exists($source)) { $firstDoc = $daoDoc->selectById($infos['document_id']); $d = $firstDoc->generalInfos['page'][$infos['document_page']]['size']; $this->config->pagesDimensions[$page] = array($this->cssWidth, $d[1] * ($this->cssWidth / $d[0])); @@ -2425,7 +2429,6 @@ height="0" width="0" style="display:none;visibility:hidden"> $this->lessVariables['edge-right-offset'] = 0; $this->lessVariables['edges-opacity'] = 1; - $this->lessVariables['page-number-color'] = wsHTML5::colorToCSS($this->theme->parametres->colorPageNumber); $this->lessVariables['display-page-number'] = $this->_lessBoolean($this->theme->parametres->displayPageNumber); $this->lessVariables['page-transition-duration'] = $this->book->parametres->mobileTransitionDuration . 's';