]> _ Git - fluidbook_tools.git/commitdiff
wip #5863 @0.75
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 14 Apr 2023 10:49:50 +0000 (12:49 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 14 Apr 2023 10:49:50 +0000 (12:49 +0200)
.idea/php.xml
src/Jobs/ProcessFile.php

index 4f7f19ec77550638be4b038547db82df522b5b01..a70e4c53c1b48e837493f709b88a0228c5b8d4c3 100644 (file)
@@ -90,5 +90,7 @@
       <path value="$PROJECT_DIR$/vendor/cubist/pdf" />
     </include_path>
   </component>
-  <component name="PhpProjectSharedConfiguration" php_language_level="8.0" />
+  <component name="PhpProjectSharedConfiguration" php_language_level="8.1">
+    <option name="suggestChangeDefaultLanguageLevel" value="false" />
+  </component>
 </project>
\ No newline at end of file
index a5b0f3e17b627bc2f680d5852995ee66f52cbab7..ff2b327b6b6fe0278171c0ac007939be6c39cf7e 100644 (file)
@@ -6,8 +6,7 @@ use Cubist\Util\Files\Files;
 use Cubist\PDF\PDFTools;
 use Fluidbook\Tools\SVG\SVGTools;
 
-class ProcessFile
-{
+class ProcessFile {
     protected $format = 'jpg';
     /**
      * @var int|string
@@ -31,8 +30,7 @@ class ProcessFile
      */
     protected $job;
 
-    public function __construct($format = 'jpg', $resolution = 150, $withGraphics = true, $withTexts = true, $version = 'html')
-    {
+    public function __construct($format = 'jpg', $resolution = 150, $withGraphics = true, $withTexts = true, $version = 'html') {
         $this->format = $format;
         $this->resolution = $resolution;
         $this->withGraphics = $withGraphics;
@@ -43,16 +41,14 @@ class ProcessFile
     /**
      * @param string $format
      */
-    public function setFormat(string $format)
-    {
+    public function setFormat(string $format) {
         $this->format = $format;
     }
 
     /**
      * @return string
      */
-    public function getFormat(): string
-    {
+    public function getFormat(): string {
         if ($this->format === 'jpeg') {
             return 'jpg';
         }
@@ -62,64 +58,56 @@ class ProcessFile
     /**
      * @param int|string $resolution
      */
-    public function setResolution(int|string $resolution)
-    {
+    public function setResolution(int|string $resolution) {
         $this->resolution = $resolution;
     }
 
     /**
      * @return int|string
      */
-    public function getResolution(): int|string
-    {
+    public function getResolution(): int|string {
         return $this->resolution;
     }
 
     /**
      * @return bool
      */
-    public function isWithGraphics(): bool
-    {
+    public function isWithGraphics(): bool {
         return $this->withGraphics;
     }
 
     /**
      * @param bool $withGraphics
      */
-    public function setWithGraphics(bool $withGraphics)
-    {
+    public function setWithGraphics(bool $withGraphics) {
         $this->withGraphics = $withGraphics;
     }
 
     /**
      * @return bool
      */
-    public function isWithTexts(): bool
-    {
+    public function isWithTexts(): bool {
         return $this->withTexts;
     }
 
     /**
      * @param bool $withTexts
      */
-    public function setWithTexts(bool $withTexts)
-    {
+    public function setWithTexts(bool $withTexts) {
         $this->withTexts = $withTexts;
     }
 
     /**
      * @return int
      */
-    public function getPage(): int
-    {
+    public function getPage(): int {
         return $this->job->getPage();
     }
 
     /**
      * @return mixed
      */
-    public function getOut()
-    {
+    public function getOut() {
         return $this->job->getOut();
     }
 
@@ -127,8 +115,7 @@ class ProcessFile
     /**
      * @return string
      */
-    public function getVersion(): string
-    {
+    public function getVersion(): string {
         if ($this->getFormat() === 'svg') {
             return 'html';
         } else if ($this->getFormat() === 'swf') {
@@ -141,30 +128,26 @@ class ProcessFile
     /**
      * @param string $version
      */
-    public function setVersion(string $version)
-    {
+    public function setVersion(string $version) {
         $this->version = $version;
     }
 
     /**
      * @return ProcessPage
      */
-    public function getJob(): ProcessPage
-    {
+    public function getJob(): ProcessPage {
         return $this->job;
     }
 
     /**
      * @param ProcessPage $job
      */
-    public function setJob(ProcessPage $job)
-    {
+    public function setJob(ProcessPage $job) {
         $this->job = $job;
         return $this;
     }
 
-    public function getPath($force = false)
-    {
+    public function getPath($force = false) {
         $dir = rtrim($this->getOut() . $this->getVersion(), '/') . '/';
         $minsize = 1;
         $res = '';
@@ -205,8 +188,7 @@ class ProcessFile
         return $res;
     }
 
-    public function makeFile($file)
-    {
+    public function makeFile($file) {
         $lock = $file . '.lock';
         if (file_exists($lock) && filemtime($lock) > time() - 300) {
             sleep(10);
@@ -240,8 +222,7 @@ class ProcessFile
         }
     }
 
-    public function makeSVGFile($force = false)
-    {
+    public function makeSVGFile($force = false) {
         $svgFile = $this->getOut() . '/html/fp' . $this->getPage() . '.svg';
         if (!$force && file_exists($svgFile) && filesize($svgFile) > 0) {
             return $svgFile;
@@ -250,33 +231,30 @@ class ProcessFile
         return $svgFile;
     }
 
-    public function makeTextSVGFile($out)
-    {
+    public function makeTextSVGFile($out) {
         $in = $this->makeSVGFile();
         $inter = str_replace('/to', '/tp', $out);
         PDFTools::makeTextSVGFile($in, $inter);
         SVGTools::optimizeSVG($inter, $out);
     }
 
-    public function getResolutionRatio(): float
-    {
+    public function getResolutionRatio(): float {
         return $this->getJob()->getResolutionRatio();
     }
 
-    public function getMobileRatio(): float
-    {
+    public function getMobileRatio(): float {
         return $this->getJob()->getMobileFirstRatio();
     }
 
-    public function makeOptimizedSVGFile($out)
-    {
+    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);
     }
 
-    public function getSplittedPDFPage()
-    {
+    public function getSplittedPDFPage() {
         $res = $this->getOut() . 'pdf/p' . $this->getPage() . '.pdf';
         if (!file_exists($res)) {
             $this->getJob()->splitDoc();