]> _ Git - fluidbook-toolbox.git/commitdiff
wip #5991
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 5 Jun 2023 15:09:53 +0000 (17:09 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 5 Jun 2023 15:09:53 +0000 (17:09 +0200)
app/Fluidbook/Farm.php
app/Jobs/FluidbookDocumentFileProcess.php
app/Jobs/FluidbookImagesPreprocess.php
app/Models/FluidbookDocument.php
app/Models/FluidbookPublication.php

index 0d21a49b3bc403785bdb941ac213ee1de932cc48..ef9c820c8f6df82c77ae187fb670d557caae4347 100644 (file)
@@ -127,7 +127,6 @@ class Farm
             'version' => $version,
             'out' => $out];
 
-
         $cachekey = 'filefrompdf_' . hash('sha256', print_r($attrs, true));
 
         $params = array_merge($attrs, ['toolbox' => 1,
index 75a2db1c72056318fd174dce8c2eac522ecde8dc..6241d7484e259db0571c9fafc7e841963447cc0e 100644 (file)
@@ -20,25 +20,29 @@ class FluidbookDocumentFileProcess extends Base
 
     protected $finish = false;
 
-    public function __construct($document, $page, $format = 'jpg', $resolution = 150,$quality=85, $withText = true, $withGraphics = true, $version = 'html', $forceCheck = false, $forceProcess = false)
+    protected $path = "";
+
+    public function __construct($document, $page, $format = 'jpg', $resolution = 150, $quality = 85, $withText = true, $withGraphics = true, $version = 'html', $forceCheck = false, $forceProcess = false)
     {
         $this->onQueue('fluidbookprocess');
         $this->document = $document;
         $this->page = $page;
         $this->format = $format;
         $this->resolution = $resolution;
-        $this->quality=$quality;
+        $this->quality = $quality;
         $this->withGraphics = $withGraphics;
         $this->withText = $withText;
         $this->version = $version;
         $this->forceCheck = $forceCheck || $forceProcess;
         $this->forceProcess = $forceProcess;
+
+        $this->path = $this->document->_getPath($this->page, $this->format, $this->resolution, $this->quality, $this->withText, $this->withGraphics, $this->version);
     }
 
     public function handle()
     {
         $this->finish = false;
-        echo $this->document->getFile($this->page, $this->format, $this->resolution,$this->quality, $this->withText, $this->withGraphics, $this->version, $this->forceCheck, $this->forceProcess) . "\n";
+        echo $this->document->getFile($this->page, $this->format, $this->resolution, $this->quality, $this->withText, $this->withGraphics, $this->version, $this->forceCheck, $this->forceProcess) . "\n";
         $this->finish = true;
     }
 
@@ -52,11 +56,19 @@ class FluidbookDocumentFileProcess extends Base
 
     public function isOK()
     {
-        return $this->document->hasFile($this->page, $this->format, $this->resolution,$this->quality, $this->withText, $this->withGraphics, $this->version, $this->forceCheck);
+        return $this->document->hasFile($this->page, $this->format, $this->resolution, $this->quality, $this->withText, $this->withGraphics, $this->version, $this->forceCheck);
     }
 
     public function isError()
     {
         return $this->finish && !$this->isOK();
     }
+
+    /**
+     * @return mixed|string
+     */
+    public function getPath(): mixed
+    {
+        return $this->path;
+    }
 }
index 8ffe401ab8bc8c194895de5f93953c2c753d30e8..a07f2d1b2f2d88e1964bd9c9dc68562c06dce13e 100644 (file)
@@ -86,6 +86,9 @@ class FluidbookImagesPreprocess extends Base
                 $done++;
             }
         }
+        if (rand(1, 10) === 5) {
+            echo $done . '/' . $nbjobs . "\n";
+        }
         return $done === $nbjobs;
     }
 
@@ -93,11 +96,14 @@ class FluidbookImagesPreprocess extends Base
     {
         $c = $this->book->composition[$page];
         $doc = $this->book->getDocument($page);
-        $job = new FluidbookDocumentFileProcess($doc, $c[1], $format, $resolution, $withText, $withGraphics, $version);
+        $quality = $this->book->JPEGQuality ?: 85;
+        $job = new FluidbookDocumentFileProcess($doc, $c[1], $format, $resolution, $quality, $withText, $withGraphics, $version);
+        $this->jobs[] = $job;
         if ($job->isDone()) {
             return;
         }
+        echo $job->getPath() . "\n";
         dispatch($job);
-        $this->jobs[] = $job;
+
     }
 }
index e78c9566ec3c5abdb9dd6519d858220e6b1db188..f04ae8a5d516b32dffad722d4ab14b4b55a61bbf 100644 (file)
@@ -250,8 +250,6 @@ class FluidbookDocument extends ToolboxModel
         }
         if ($format === 'svg') {
             $version = 'html';
-        } else if ($format === 'swf') {
-            $version = '';
         }
 
         if ($resolution === 'thumb') {
@@ -280,15 +278,13 @@ class FluidbookDocument extends ToolboxModel
             }
             $file .= '.svg';
         } else if ($format === 'png' || $format === 'jpg') {
-            $q = ($format === 'jpg' && $quality !== 85) ? '-' . $quality : '';
+            $q = ($format === 'jpg' && $quality != 85) ? '-' . $quality : '';
             $prefix = $withText ? 't' : 'h';
             if ($resolution === 'thumb') {
                 $file = $dir . 'p' . $page . $q . '.' . $format;
             } else {
                 $file = $dir . $prefix . $page . '-' . $resolution . $q . '.' . $format;
             }
-        } else if ($format === 'swf') {
-            $file = $dir . 'p' . $page . '.' . $format;
         }
 
         return $file;
@@ -297,7 +293,7 @@ class FluidbookDocument extends ToolboxModel
     protected function fileCacheKey($page, $format = 'jpg', $resolution = 150, $quality = 85, $withText = true, $withGraphics = true, $version = 'html')
     {
         $this->_normalize($format, $resolution, $quality, $withText, $withGraphics, $version);
-        return 'FluidbookDocument_' . $this->id . '_' . $page . '_' . $format . '_' . $resolution . '_' . ($withText ? '1' : '0') . '_' . ($withGraphics ? '1' : '0') . '_' . $version;
+        return 'FluidbookDocument_' . $this->id . '_' . $page . '_' . $format . '_' . $resolution . '_' . $quality . '_' . ($withText ? '1' : '0') . '_' . ($withGraphics ? '1' : '0') . '_' . $version;
     }
 
     public function getFile($page, $format = 'jpg', $resolution = 150, $quality = 85, $withText = true, $withGraphics = true, $version = 'html', $forceCheck = false, $forceProcess = false)
index e09f22219f2ccbbfa375c826643046cf2aeac801..c09bccca4b8159c1732f490885edfccdf9560579 100644 (file)
@@ -374,7 +374,7 @@ class FluidbookPublication extends ToolboxSettingsModel
                 return Farm::getFileFromPDF($thumbpdf, $page, $format, $resolution, $this->JPEGQuality, $withText, $withGraphics, $version, null, $force);
             }
         }
-        return $this->getFile($page, $format, $resolution, $this->JPEGQuality, $withText, $withGraphics, $version, $force);
+        return $this->getFile($page, $format, $resolution, $withText, $withGraphics, $version, $force);
 
     }