From ff7791f63d9884124dd9259919b4914c6ead60e9 Mon Sep 17 00:00:00 2001 From: "vincent@cubedesigners.com" Date: Mon, 11 Jan 2021 17:13:17 +0000 Subject: [PATCH] wait #4186 @0.5 --- inc/ws/Util/class.ws.exporter.php | 3 ++- inc/ws/Util/class.ws.tools.php | 20 ++++++++++++++++++- .../html5/master/class.ws.html5.compiler.php | 2 ++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/inc/ws/Util/class.ws.exporter.php b/inc/ws/Util/class.ws.exporter.php index 2f8a9de16..5171da710 100644 --- a/inc/ws/Util/class.ws.exporter.php +++ b/inc/ws/Util/class.ws.exporter.php @@ -16,7 +16,8 @@ class wsExporter public $x; public $ftpPassiveMode = false; - const VINCENT = "paris.cubedesigners.com"; + //const VINCENT = "paris.cubedesigners.com"; + const VINCENT = "tortuga.enhydra.fr"; public function exportCollection($collectionId, $os) { diff --git a/inc/ws/Util/class.ws.tools.php b/inc/ws/Util/class.ws.tools.php index 9aa8d1b93..51171c8d3 100644 --- a/inc/ws/Util/class.ws.tools.php +++ b/inc/ws/Util/class.ws.tools.php @@ -57,7 +57,24 @@ class wsTools $webvideo->execute(); } - public static function optimizeSVG($in, $out) + + public static function optimizeSVG($in, $out = null) + { + if (null === $out) { + $e = explode('.', $in); + $ext = array_pop($e); + array_push($e, 'o'); + array_push($e, $ext); + $out = implode('.', $e); + } + + if (file_exists($out) && filemtime($in) <= filemtime($out)) { + return; + } + return self::_optimizeSVG($in, $out); + } + + public static function _optimizeSVG($in, $out) { $cmd = "timeout -s 1 120 /usr/local/bin/svgcleaner --allow-bigger-file --paths-coordinates-precision 3 --copy-on-error --stdout $in"; $svg = `$cmd`; @@ -66,6 +83,7 @@ class wsTools } $svg = self::_disablePreserveRatio($svg); file_put_contents($out, $svg); + return $out; } protected static function _disablePreserveRatio($in) diff --git a/inc/ws/Util/html5/master/class.ws.html5.compiler.php b/inc/ws/Util/html5/master/class.ws.html5.compiler.php index d03b9543b..a10d6f12e 100644 --- a/inc/ws/Util/html5/master/class.ws.html5.compiler.php +++ b/inc/ws/Util/html5/master/class.ws.html5.compiler.php @@ -1448,6 +1448,8 @@ class wsHTML5Compiler protected function addSVGSymbolFromFile($svg, $symbolName) { + $svg = wsTools::optimizeSVG($svg); + $xml = simplexml_load_string(file_get_contents($svg)); $viewBox = (string)$xml['viewBox']; -- 2.39.5