From ce47377196b7059cab044cb9147538dc622c0b1f Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Fri, 14 Apr 2023 16:21:44 +0200 Subject: [PATCH] wip #5863 @0.75 --- src/Jobs/ProcessFile.php | 4 ++-- src/SVG/SVGTools.php | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Jobs/ProcessFile.php b/src/Jobs/ProcessFile.php index ff2b327..c85e224 100644 --- a/src/Jobs/ProcessFile.php +++ b/src/Jobs/ProcessFile.php @@ -246,11 +246,11 @@ class ProcessFile { return $this->getJob()->getMobileFirstRatio(); } + + public function makeOptimizedSVGFile($out) { $in = $this->makeSVGFile(); SVGTools::optimizeSVGImages($in, $out, $this->getResolution()); - $beforeOpt = str_replace('.svg', '.orig.svg', $out); - copy($out, $beforeOpt); SVGTools::optimizeSVG($out, $out); } diff --git a/src/SVG/SVGTools.php b/src/SVG/SVGTools.php index 64fe55e..1fcb6be 100644 --- a/src/SVG/SVGTools.php +++ b/src/SVG/SVGTools.php @@ -54,6 +54,9 @@ class SVGTools { public static function _optimizeSVG($in, $out) { + $beforeOpt = str_replace('.svg', '.orig.svg', $in); + copy($in, $beforeOpt); + $svg = shell_exec('timeout -s 1 120 ' . FluidbookTools::tools_path('svgcleaner/svgcleaner', true) . ' --allow-bigger-file --paths-coordinates-precision 3 --copy-on-error --stdout ' . $in); if (!$svg) { $svg = file_get_contents($in); @@ -153,7 +156,7 @@ class SVGTools { $cli->setArg('s', $source); $cli->setArg('d', $dest); $cli->execute(); - if(!stristr($cli->getOutput(),'done')){ + if (!stristr($cli->getOutput(), 'done')) { $cli->dd(); } -- 2.39.5