]> _ Git - cubist_util.git/commitdiff
wait #5953 @0.25
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 31 May 2023 09:17:09 +0000 (11:17 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 31 May 2023 09:17:09 +0000 (11:17 +0200)
src/Graphics/Image.php

index 8a06bbd6dc250cb302198f7b3b9e6272622bccbb..f7f21ab3820b9e255aba18eb2638da8a4ce10139 100644 (file)
@@ -71,7 +71,9 @@ class Image
             $res = [$oam['width'], $oam['height']];
         } else if ($ext === 'zip') {
             $zip = ZipAnimation::getZIPData($path);
-            $res = [$zip['width'], $zip['height']];
+            if (null !== $zip) {
+                $res = [$zip['width'], $zip['height']];
+            }
         } else if ($ext === 'html') {
             $htmlContent = file_get_contents($path);
             if (stristr($htmlContent, '<div id="lottie"></div>')) {
@@ -104,8 +106,8 @@ class Image
     }
 
     /**
-     * @throws \Exception
      * @return string
+     * @throws \Exception
      */
     public static function fixSVGDimensions($source, $preserveAspectRatio = "none")
     {
@@ -121,7 +123,11 @@ class Image
         $attr = $svg->attributes();
         $dim = self::getimagesize($source);
         if ($preserveAspectRatio) {
-            $svg->addAttribute('preserveAspectRatio', $preserveAspectRatio);
+            if (!isset($attr->preserveAspectRatio)) {
+                $svg->addAttribute('preserveAspectRatio', $preserveAspectRatio);
+            } else {
+                $attr->preserveAspectRatio = $preserveAspectRatio;
+            }
         }
         if (!isset($attr['width'], $attr['height'])) {
             $svg->addAttribute('width', $dim[0]);