From 757cd1255217f1184d76dca128b1f9f171545f9f Mon Sep 17 00:00:00 2001 From: "vincent@cubedesigners.com" Date: Tue, 20 Oct 2020 08:06:30 +0000 Subject: [PATCH] wait #3972 @1 --- inc/ws/Metier/class.ws.document.php | 13 ++++++++----- inc/ws/Util/class.ws.tools.php | 15 ++++++++++++--- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/inc/ws/Metier/class.ws.document.php b/inc/ws/Metier/class.ws.document.php index 828838a95..9e57934d8 100644 --- a/inc/ws/Metier/class.ws.document.php +++ b/inc/ws/Metier/class.ws.document.php @@ -384,7 +384,7 @@ class wsDocument extends cubeMetier return false; } - public function getFile($page, $format = 'jpg', $resolution = 150, $withText = true, $withGraphics = true, $version = 'html') + public function getFile($page, $format = 'jpg', $resolution = 150, $withText = true, $withGraphics = true, $version = 'html', $force = false) { if ($format === 'jpeg') { $format = 'jpg'; @@ -436,9 +436,12 @@ class wsDocument extends cubeMetier $do = true; } else if (isset($reffile) && filemtime($file) < filemtime($reffile)) { $do = true; + } else if ($format === 'svg') { + $t = filemtime($file); + $do = $t < 1603181003 && $t > 1602662603; } - if ($do) { + if ($do || $force) { $this->makeFile($file, $page, $format, $resolution, $withText, $withGraphics, $version); } return $file; @@ -501,11 +504,11 @@ class wsDocument extends cubeMetier if ($force) { $this->addToLog('Processing page #' . $page); // Thumb for composition panel - $this->makeMiniShot($page); + $this->getFile($page, 'jpg', 'thumb', true, true, '', true); // Image for link editor - $this->getFile($page,'swf'); + $this->getFile($page, 'swf', 150, true, true, '', true); // Make SVG base file - $this->makeSVGFile($page, false); + $this->makeSVGFile($page, true); } } diff --git a/inc/ws/Util/class.ws.tools.php b/inc/ws/Util/class.ws.tools.php index 44d4da1e1..9aa8d1b93 100644 --- a/inc/ws/Util/class.ws.tools.php +++ b/inc/ws/Util/class.ws.tools.php @@ -62,17 +62,26 @@ class wsTools $cmd = "timeout -s 1 120 /usr/local/bin/svgcleaner --allow-bigger-file --paths-coordinates-precision 3 --copy-on-error --stdout $in"; $svg = `$cmd`; if ($svg == '') { - copy($in, $out); - return; + $svg = file_get_contents($in); } + $svg = self::_disablePreserveRatio($svg); file_put_contents($out, $svg); } + protected static function _disablePreserveRatio($in) + { + $str = 'preserveAspectRatio="none"'; + if (strpos($in, $str) !== false) { + return $in; + } + return str_replace("/', '', $svg); - $svg = substr_replace($svg, ' preserveAspectRatio="none" ', 5, 0); + $svg = self::_disablePreserveRatio($svg); $osvg = preg_replace_callback('|\]*)\>|', function ($matches) use ($resolution) { return wsTools::optimizeRaster($matches, $resolution); -- 2.39.5