From 6d7c98d2192c8757f541c22d94007f50595e4ea8 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Wed, 8 Mar 2023 19:34:36 +0100 Subject: [PATCH] wip #5776 @0.5 --- src/Graphics/Image.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Graphics/Image.php b/src/Graphics/Image.php index 4046557..4c3c1e4 100644 --- a/src/Graphics/Image.php +++ b/src/Graphics/Image.php @@ -24,7 +24,7 @@ class Image throw new \Exception('File ' . $path . ' does not exist'); } - $allowedExtensions = ['svg', 'oam', 'zip', 'jpeg', 'jpg', 'gif', 'png', 'webm', 'pdf']; + $allowedExtensions = ['svg', 'oam', 'zip', 'jpeg', 'jpg', 'gif', 'png', 'webm', 'pdf', 'html']; $ext = Files::getExtension($path); if (!in_array($ext, $allowedExtensions)) { @@ -55,6 +55,14 @@ class Image } else if ($ext === 'zip') { $zip = ZipAnimation::getZIPData($path); $res = [$zip['width'], $zip['height']]; + } else if ($ext === 'html') { + $htmlContent = 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']]; + } + } } else { $res = getimagesize($path); } -- 2.39.5