From 50693453a2ec7aa03730714d1ad33200d79d6bd3 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Tue, 28 Nov 2023 15:01:22 +0100 Subject: [PATCH] wait #6530 --- .idea/fluidbook_tools.iml | 2 ++ .idea/php.xml | 1 + src/Links/LayerLink.php | 1 + src/Links/ZoomLink.php | 15 +++++++++------ src/SVG/SVGTools.php | 2 +- 5 files changed, 14 insertions(+), 7 deletions(-) diff --git a/.idea/fluidbook_tools.iml b/.idea/fluidbook_tools.iml index ecd464b..2fc5484 100644 --- a/.idea/fluidbook_tools.iml +++ b/.idea/fluidbook_tools.iml @@ -6,6 +6,7 @@ + @@ -99,6 +100,7 @@ + diff --git a/.idea/php.xml b/.idea/php.xml index c271f25..ac96ba9 100644 --- a/.idea/php.xml +++ b/.idea/php.xml @@ -103,6 +103,7 @@ + diff --git a/src/Links/LayerLink.php b/src/Links/LayerLink.php index 270229f..ac65a8e 100644 --- a/src/Links/LayerLink.php +++ b/src/Links/LayerLink.php @@ -28,6 +28,7 @@ class LayerLink extends ImageLink public function getCSS() { $attributes = $this->getZoomAttributes(); + if (!$this->rightClone) { ZoomLink::generateImage($attributes, $this->compiler, 'layerlink', 'layer'); } diff --git a/src/Links/ZoomLink.php b/src/Links/ZoomLink.php index aefa38f..267d4c0 100644 --- a/src/Links/ZoomLink.php +++ b/src/Links/ZoomLink.php @@ -4,6 +4,7 @@ namespace Fluidbook\Tools\Links; use Cubist\Util\CommandLine\Imagemagick; use Cubist\Util\CommandLine\Poppler; +use Cubist\Util\Files\Files; use Cubist\Util\Graphics\PDF; use Cubist\Util\Text; use Fluidbook\Tools\Compiler\CompilerInterface; @@ -160,6 +161,7 @@ class ZoomLink extends NormalLink { $cache = $compiler->getCacheDir("zoomarea/" . $cachedir); + $leftHeight = min($h, $compiler->getHeightForLinks($attributes['page']) - $y); $leftWidth = min($w, $compiler->getWidthForLinks($attributes['page']) - $x); @@ -169,7 +171,8 @@ class ZoomLink extends NormalLink { $extractPage, $leftArea, null, $extractOptions, $cache); - if (!file_exists($leftfile)) { + + if (Files::isEmpty($leftfile)) { throw new \Exception('Failed to generate image with ' . json_encode($attributes)); } @@ -188,19 +191,19 @@ class ZoomLink extends NormalLink { ['x' => 0, 'y' => $y, 'width' => $diff, 'height' => $h], null, $extractOptions, $cache); - if (!file_exists($rightfile)) { + if (Files::isEmpty($rightfile)) { throw new \Exception('Error generating right part ' . $rightfile); } $both = $cache . hash('sha256', $leftfile . $rightfile) . '.' . $ext; - if (!file_exists($both)) { + if (Files::isEmpty($both)) { if ($ext === 'svg') { SVGTools::append($leftfile, $rightfile, $both, 'h'); } else { Imagemagick::append(array($leftfile, $rightfile), $both, 'horizontal'); } } - if (!file_exists($both)) { + if (Files::isEmpty($both)) { throw new \Exception('Error glueing ' . $leftfile . ' and ' . $rightfile); } } else { @@ -209,7 +212,7 @@ class ZoomLink extends NormalLink { if ($trim) { $trimmed = str_replace('.jpg', '.trim.' . $ext, $both); - if (!file_exists($trimmed) || filemtime($trimmed) < filemtime($both)) { + if (Files::isEmpty($trimmed) || filemtime($trimmed) < filemtime($both)) { Imagemagick::trim($both, $trimmed); } $both = $trimmed; @@ -224,7 +227,7 @@ class ZoomLink extends NormalLink { // dd($both); - if (!file_exists($both)) { + if (Files::isEmpty($both)) { Log::error('Failed generate image ' . json_encode($attributes)); } $dest = 'data/links/' . $save . '_' . $attributes['id'] . '.' . $ext; diff --git a/src/SVG/SVGTools.php b/src/SVG/SVGTools.php index 6dce379..9d44ee9 100644 --- a/src/SVG/SVGTools.php +++ b/src/SVG/SVGTools.php @@ -178,9 +178,9 @@ class SVGTools $cli->setArg('d', $dest); $cli->execute(); if (!stristr($cli->getOutput(), 'done')) { - $cli->dd(); } + } public static function append($first, $second, $dest, $direction = 'h') -- 2.39.5