]> _ Git - cubeextranet.git/commitdiff
wip #4726 @1.5
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Thu, 30 Sep 2021 14:29:40 +0000 (14:29 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Thu, 30 Sep 2021 14:29:40 +0000 (14:29 +0000)
inc/ws/Metier/class.ws.book.parametres.php
inc/ws/Metier/class.ws.book.php
inc/ws/Metier/class.ws.document.php
inc/ws/Util/html5/svgtocanvas/class.ws.html5.compiler.php

index bf283495d7e7ee19539ae3186865e6a32e469582..7ff4d7276471e13d20b1a329189b06bb71680b59 100644 (file)
@@ -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'),
index 68e9bf4f5f4136daad1fa70d22eac9545bdc8bba..3749e6d987eb13d55c004a08fce51c48d2c122c5 100644 (file)
@@ -92,6 +92,14 @@ class wsBook extends cubeMetier
             $dao = new wsDAODocument($core->con);\r
             $this->_docs[$p['document_id']] = $dao->selectById($p['document_id']);\r
         }\r
+        if ($format === 'jpg') {\r
+            $q = $this->parametres->JPEGQuality ?? 85;\r
+        } else {\r
+            $q = 85;\r
+        }\r
+        if ($q != 85) {\r
+            $resolution .= '-' . $q;\r
+        }\r
         $doc = $this->_docs[$p['document_id']];\r
         return $doc->getFile($p['document_page'], $format, $resolution, $withText, $withGraphics, $version, $force);\r
     }\r
index e50ef3b0720e5d06329dddcea4c655f5c7f2a07c..14ecf99326856bb2d034235bbe1b63946f6f8c33 100644 (file)
@@ -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);
index 74d72502f861d05b1342ec6821daaea20cb7b202..d64fd7db83ce5a6f569a407093cb7281bafef8e6 100644 (file)
@@ -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"></iframe></noscript>
             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"></iframe></noscript>
         $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';