]> _ Git - fluidbook-toolbox.git/commitdiff
wip #7340 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 19 Feb 2025 09:04:18 +0000 (10:04 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 19 Feb 2025 09:04:18 +0000 (10:04 +0100)
app/Console/Commands/FluidbookFluidbookPageProcess.php
app/Fluidbook/Compiler/Images.php
app/Http/Controllers/Admin/Operations/FluidbookPublication/CompositionOperation.php
app/Http/Controllers/Admin/Operations/FluidbookPublication/Services/GetPageFromWebsiteOperation.php
app/Jobs/FluidbookDocumentFileProcess.php
app/Jobs/FluidbookImagesPreprocess.php

index 9ca1231d1be123e6feb66133eb7938b83060de61..c2852ee1ba44b51b8e02817261e81c64b989dcc5 100644 (file)
@@ -27,15 +27,15 @@ class FluidbookFluidbookPageProcess extends ToolboxCommand
         $fluidbook = FluidbookPublication::withoutGlobalScopes()->find($id);
         $files = [
             // Thumbnail
-            ['jpg', 'thumb', true, true, ''],
+            ['jpg', 'thumb', true, true, false, ''],
             // Images
-            ['jpg', 150, false, true, 'html'],
+            ['jpg', 150, false, true, false, 'html'],
             // Texts
-            ['svg', 150, true, false, 'html'],
+            ['svg', 150, true, false, false, 'html'],
         ];
 
         foreach ($files as $file) {
-            $fluidbook->getFile($this->argument('page'), $file[0], $file[1], $file[2], $file[3], $file[4], true);
+            $fluidbook->getFile($this->argument('page'), $file[0], $file[1], $file[2], $file[3], $file[4], $file[5], true);
         }
     }
 }
index 9df28a9a98e68ab5cfb72fb014db52b76ef1b602..c0dd24ccbb4453d6c5abea69f24a6ae759b7b2d2 100644 (file)
@@ -90,7 +90,7 @@ trait Images
 
                 if ($thisimagesvg) {
                     $source = $this->getFluidbook()->getFile($page, 'svg', 150, true,
-                        in_array($page, $this->config->vectorPages), 'html');
+                        in_array($page, $this->config->vectorPages),false, 'html');
                     $filesToCopy[$source] = 'data/contents/p' . $page . '.svg';
                 }
 
index a47bcb52bfaf58f4c3609a787bf846e90eabcc67..5b069386fe671627e4ab7f0fdc3f3568d50b2925 100644 (file)
@@ -81,7 +81,7 @@ trait CompositionOperation
     {
         /** @var FluidbookDocument $doc */
         $doc = FluidbookDocument::withoutGlobalScopes()->find($doc_id);
-        $path = $doc->getFile($doc_page, 'jpg', 'thumb', true, true, '');
+        $path = $doc->getFile($doc_page, 'jpg', 'thumb', 85, true, true, false, '');
         if (filesize($path) === 0) {
             for ($i = 1; $i <= 8; $i++) {
                 clearstatcache();
index 1c3c98774c308b3f7de757590dcc0e39677cf5af..c0ba2a65485c4adcb70d003371e70de614b634a6 100644 (file)
@@ -20,7 +20,7 @@ trait GetPageFromWebsiteOperation
     {
         /** @var FluidbookPublication $publication */
         $publication = FluidbookPublication::withoutGlobalScopes()->find($fluidbook);
-        $path = $publication->getFile($page, 'jpg', 150, true, true, '');
+        $path = $publication->getFile($page, 'jpg', 150, true, true, false, '');
         return XSendFileController::sendfile($path);
     }
 }
index 25b78f2959c718bd17df14e622fd3290302531c3..8aafdc11a104a85ef29fc3f3a2c9182e22d69c41 100644 (file)
@@ -19,12 +19,13 @@ class FluidbookDocumentFileProcess extends Base
     protected $version;
     protected $forceCheck;
     protected $forceProcess;
+    protected $transparent;
 
     protected $path = "";
 
     protected $log = '';
 
-    public function __construct($document, $page, $format = 'jpg', $resolution = 150, $quality = 85, $withText = true, $withGraphics = true, $version = 'html', $forceCheck = false, $forceProcess = false)
+    public function __construct($document, $page, $format = 'jpg', $resolution = 150, $quality = 85, $withText = true, $withGraphics = true, $transparent = false, $version = 'html', $forceCheck = false, $forceProcess = false)
     {
         $this->onQueue('fluidbookprocess');
         $this->document = $document;
@@ -34,17 +35,18 @@ class FluidbookDocumentFileProcess extends Base
         $this->quality = $quality;
         $this->withGraphics = $withGraphics;
         $this->withText = $withText;
+        $this->transparent = $transparent;
         $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);
+        $this->path = $this->document->_getPath($this->page, $this->format, $this->resolution, $this->quality, $this->withText, $this->withGraphics, $this->transparent, $this->version);
     }
 
     public function handle()
     {
         try {
-            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->transparent, $this->version, $this->forceCheck, $this->forceProcess) . "\n";
         } catch (\Exception $e) {
             Log::warning($e->getMessage());
             $this->log = $e->getMessage();
@@ -73,7 +75,7 @@ class FluidbookDocumentFileProcess extends Base
 
     public function isOK($forceCheck = false)
     {
-        return $this->document->hasFile($this->page, $this->format, $this->resolution, $this->quality, $this->withText, $this->withGraphics, $this->version, $this->forceCheck || $forceCheck);
+        return $this->document->hasFile($this->page, $this->format, $this->resolution, $this->quality, $this->withText, $this->withGraphics, $this->version, $this->transparent, $this->forceCheck || $forceCheck);
     }
 
     public function isError()
index ab027f7d9f69714e47997a26bd50214d49066ec8..a8f078b18578749a5d375aeb6f8d4e8944c22292 100644 (file)
@@ -42,6 +42,7 @@ class FluidbookImagesPreprocess extends Base
         $resolutions = Compiler::getBookResolutions($this->book);
         $rasterizePages = ArrayUtil::parseRange($settings->rasterizePages);
         $vectorPages = array_diff(ArrayUtil::parseRange($settings->vectorPages), $rasterizePages);
+        $transparent = $this->book->getAttribute('transparentPage', false);
 
         switch ($settings->mobileVersion) {
             case 'html5-desktop':
@@ -70,11 +71,11 @@ class FluidbookImagesPreprocess extends Base
             $pageBackgroundsToGenerate = $thisrasterize ? [true] : $globalBackgroundToGenerate;
             foreach ($resolutions as $r) {
                 foreach ($pageBackgroundsToGenerate as $withText) {
-                    $this->getFile($page, $settings->imageFormat, $r, $withText, true, $imdir);
+                    $this->getFile($page, $settings->imageFormat, $r, $withText, true, $transparent, $imdir);
                 }
             }
             if ($thisimagesvg) {
-                $this->getFile($page, 'svg', 150, true, in_array($page, $vectorPages), 'html');
+                $this->getFile($page, 'svg', 150, true, in_array($page, $vectorPages), false, 'html');
             }
             $this->getFile($page, $settings->imageFormat, 'thumb');
         }
@@ -136,12 +137,12 @@ class FluidbookImagesPreprocess extends Base
         return $missing <= 0;
     }
 
-    protected function getFile($page, $format = 'jpg', $resolution = 150, $withText = true, $withGraphics = true, $version = 'html')
+    protected function getFile($page, $format = 'jpg', $resolution = 150, $withText = true, $withGraphics = true, $transparent = false, $version = 'html')
     {
         $c = $this->book->getComposition()[$page];
         $doc = $this->book->getDocument($page);
         $quality = $this->book->JPEGQuality ?: 85;
-        $job = new FluidbookDocumentFileProcess($doc, $c[1], $format, $resolution, $quality, $withText, $withGraphics, $version);
+        $job = new FluidbookDocumentFileProcess($doc, $c[1], $format, $resolution, $quality, $withText, $withGraphics, $transparent, $version);
         $this->jobs[] = $job;
         if ($job->isDone()) {
             return;