From b2d41898813677fba49de8c923e46cad159396fa Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Fri, 5 Jan 2024 15:53:28 +0100 Subject: [PATCH] wip #6611 @0.25 --- src/Graphics/Image.php | 9 +++------ src/Graphics/Lottie.php | 28 ++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 6 deletions(-) create mode 100644 src/Graphics/Lottie.php diff --git a/src/Graphics/Image.php b/src/Graphics/Image.php index 4d787dd..3f326c2 100644 --- a/src/Graphics/Image.php +++ b/src/Graphics/Image.php @@ -90,12 +90,9 @@ class Image $res = [$zip['width'], $zip['height']]; } } else if ($ext === 'html') { - $htmlContent = Text::normalizeLines(file_get_contents($path)); - if (stristr($htmlContent, '
')) { - if (preg_match('/var animationData = (\{.*\})/', $htmlContent, $m)) { - $ad = json_decode(trim($m[1]), true); - $res = [$ad['w'], $ad['h']]; - } + $lottie = Lottie::getAnimationDataFromHTMLFile($path); + if ($lottie) { + $res = [$lottie['w'], $lottie['h']]; } } else { for ($i = 0; $i <= 5; $i++) { diff --git a/src/Graphics/Lottie.php b/src/Graphics/Lottie.php new file mode 100644 index 0000000..2451829 --- /dev/null +++ b/src/Graphics/Lottie.php @@ -0,0 +1,28 @@ +')) { + if (preg_match('/var animationData = (\{.*\})/', $htmlContent, $m)) { + return json_decode(trim($m[1]), true); + } + } + return false; + } + +} \ No newline at end of file -- 2.39.5