From: Vincent Vanwaelscappel Date: Wed, 19 Feb 2025 09:04:18 +0000 (+0100) Subject: wip #7340 @0.5 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=b1a52adbe1b86484ed724291c47d156d36e430f5;p=fluidbook-toolbox.git wip #7340 @0.5 --- diff --git a/app/Console/Commands/FluidbookFluidbookPageProcess.php b/app/Console/Commands/FluidbookFluidbookPageProcess.php index 9ca1231d1..c2852ee1b 100644 --- a/app/Console/Commands/FluidbookFluidbookPageProcess.php +++ b/app/Console/Commands/FluidbookFluidbookPageProcess.php @@ -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); } } } diff --git a/app/Fluidbook/Compiler/Images.php b/app/Fluidbook/Compiler/Images.php index 9df28a9a9..c0dd24ccb 100644 --- a/app/Fluidbook/Compiler/Images.php +++ b/app/Fluidbook/Compiler/Images.php @@ -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'; } diff --git a/app/Http/Controllers/Admin/Operations/FluidbookPublication/CompositionOperation.php b/app/Http/Controllers/Admin/Operations/FluidbookPublication/CompositionOperation.php index a47bcb52b..5b069386f 100644 --- a/app/Http/Controllers/Admin/Operations/FluidbookPublication/CompositionOperation.php +++ b/app/Http/Controllers/Admin/Operations/FluidbookPublication/CompositionOperation.php @@ -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(); diff --git a/app/Http/Controllers/Admin/Operations/FluidbookPublication/Services/GetPageFromWebsiteOperation.php b/app/Http/Controllers/Admin/Operations/FluidbookPublication/Services/GetPageFromWebsiteOperation.php index 1c3c98774..c0ba2a654 100644 --- a/app/Http/Controllers/Admin/Operations/FluidbookPublication/Services/GetPageFromWebsiteOperation.php +++ b/app/Http/Controllers/Admin/Operations/FluidbookPublication/Services/GetPageFromWebsiteOperation.php @@ -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); } } diff --git a/app/Jobs/FluidbookDocumentFileProcess.php b/app/Jobs/FluidbookDocumentFileProcess.php index 25b78f295..8aafdc11a 100644 --- a/app/Jobs/FluidbookDocumentFileProcess.php +++ b/app/Jobs/FluidbookDocumentFileProcess.php @@ -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() diff --git a/app/Jobs/FluidbookImagesPreprocess.php b/app/Jobs/FluidbookImagesPreprocess.php index ab027f7d9..a8f078b18 100644 --- a/app/Jobs/FluidbookImagesPreprocess.php +++ b/app/Jobs/FluidbookImagesPreprocess.php @@ -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;