]> _ Git - fluidbook_tools.git/commitdiff
wip #6076 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 26 Jun 2023 07:50:41 +0000 (09:50 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 26 Jun 2023 07:50:41 +0000 (09:50 +0200)
src/Links/ZoomLink.php
src/SVG/SVGTools.php

index c10b8b2786d77f194d7076bf4e40eb531184eda1..90a28800b4095996f8a3096fcf48e0e6db00f375 100644 (file)
@@ -7,6 +7,7 @@ use Cubist\Util\CommandLine\Poppler;
 use Cubist\Util\Graphics\PDF;
 use Cubist\Util\Text;
 use Fluidbook\Tools\Compiler\CompilerInterface;
+use Fluidbook\Tools\SVG\SVGTools;
 
 class ZoomLink extends NormalLink {
     protected $maxzoom_default = 2;
@@ -152,7 +153,12 @@ class ZoomLink extends NormalLink {
 
         $cache = $compiler->getCacheDir("zoomarea/" . $cachedir);
 
-        $leftArea = ['x' => $x, 'y' => $y, 'width' => $w, 'height' => $h];
+
+        $leftHeight = min($h, $compiler->getHeightForLinks() - $y);
+        $leftWidth = min($w, $compiler->getWidthForLinks() - $x);
+
+        $leftArea = ['x' => $x, 'y' => $y, 'width' => $leftWidth, 'height' => $leftHeight];
+
         $leftfile = PDF::extractArea($pdfpath,
             $extractPage,
             $leftArea,
@@ -179,7 +185,11 @@ class ZoomLink extends NormalLink {
 
             $both = $cache . hash('sha256', $leftfile . $rightfile) . '.' . $ext;
             if (!file_exists($both)) {
-                Imagemagick::append(array($leftfile, $rightfile), $both, 'horizontal');
+                if ($ext === 'svg') {
+                    SVGTools::append($leftfile, $rightfile, $both, 'h');
+                } else {
+                    Imagemagick::append(array($leftfile, $rightfile), $both, 'horizontal');
+                }
             }
             if (!file_exists($both)) {
                 throw new \Exception('Error glueing ' . $leftfile . ' and ' . $rightfile);
index 240233cb01fefcee18a5c46cbc14ed26fd1bfb7e..a948022cd5b5b4a3a63e9cf4617dffd7a4c86a91 100644 (file)
@@ -162,4 +162,14 @@ class SVGTools {
             $cli->dd();
         }
     }
+
+    public static function append($first, $second, $dest, $direction = 'h') {
+        $cli = new CommandLine('python3');
+        $cli->setArg(null, '/usr/local/svg_stack/svg_stack.py');
+        $cli->setArg('direction', $direction);
+        $cli->setArg(null, $first);
+        $cli->setArg(null, $second);
+        $cli->execute();
+        file_put_contents($dest, $cli->getOutput());
+    }
 }