$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>')) {
}
/**
- * @throws \Exception
* @return string
+ * @throws \Exception
*/
public static function fixSVGDimensions($source, $preserveAspectRatio = "none")
{
$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]);