From: Vincent Vanwaelscappel Date: Wed, 22 Sep 2021 08:11:14 +0000 (+0200) Subject: wip #4697 @0.25 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=f5187c3b171b368cb5d7a384e2a1d2c8a7c825c1;p=cubist_util.git wip #4697 @0.25 --- diff --git a/src/Animations/OAMAnimation.php b/src/Animations/OAMAnimation.php new file mode 100644 index 0000000..0f0b4cc --- /dev/null +++ b/src/Animations/OAMAnimation.php @@ -0,0 +1,52 @@ +oamfile['src']; + $config = $unz . '/' . $config; + $x = simplexml_load_string(file_get_contents($config), 'SimpleXMLElement', LIBXML_NOCDATA); + $c = Xml::toObject($x); + + $props = array('default-width' => 'width', 'default-height' => 'height', 'html-page' => 'html'); + + $res = []; + foreach ($c->properties->property as $p) { + if (isset($props[$p->_name])) { + $res[$props[$p->_name]] = $p->_defaultValue; + } + } + preg_match('|/oam/([0-9a-z]+)/$|', $unz, $m); + $res['hash'] = $m[1]; + $res['url'] = '/files/oam/' . $res['hash'] . '/Assets/' . $res['html']; + return $res; + } +} \ No newline at end of file diff --git a/src/Animations/ZipAnimation.php b/src/Animations/ZipAnimation.php new file mode 100644 index 0000000..2f50773 --- /dev/null +++ b/src/Animations/ZipAnimation.php @@ -0,0 +1,26 @@ +') !== false) { + preg_match('/var animationData = (\{.*\})/', $c, $m); + $ad = json_decode(trim($m[1]), true); + $res['width'] = $ad['w']; + $res['height'] = $ad['h']; + + } + preg_match('|/zip/([0-9a-z]+)/$|', $unz, $m); + $res['hash'] = $m[1]; + $res['url'] = '/files/zip/' . $res['hash'] . '/index.html'; + return $res; + } + } +} \ No newline at end of file diff --git a/src/Graphics/Image.php b/src/Graphics/Image.php new file mode 100644 index 0000000..a14ef34 --- /dev/null +++ b/src/Graphics/Image.php @@ -0,0 +1,53 @@ +attributes(); + if (!isset($attr['width']) || !isset($attr['height'])) { + $viewbox = trim($attr['viewBox']); + $e = explode(' ', $viewbox); + $width = (float)$e[2]; + $height = (float)$e[3]; + } else { + $width = (float)$attr['width']; + $height = (float)$attr['height']; + } + $res = array( + $width, + $height + ); + } else if ($ext === 'oam') { + $oam = OAMAnimation::getOAMData($path); + $res = [$oam['width'], $oam['height']]; + } else if ($ext === 'zip') { + $zip = ZipAnimation::getZIPData($path); + $res = [$zip['width'], $zip['height']]; + } else { + $res = getimagesize($path); + } + if (!is_array($res)) { + $res = false; + } else { + $res = array_slice($res, 0, 2, true); + } + self::$_imagesizeCache[$path] = $res; + return $res; + } +} \ No newline at end of file