mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-03 16:51:40 +09:00
Fix fatal error when trying to resize animated WebP using GD
This commit is contained in:
parent
d519cd2516
commit
13e8445309
2 changed files with 18 additions and 1 deletions
|
|
@ -568,7 +568,7 @@ class FileHandler
|
|||
{
|
||||
$source = @imagecreatefrombmp($source_file);
|
||||
}
|
||||
elseif ($type === 'webp' && function_exists('imagecreatefromwebp'))
|
||||
elseif ($type === 'webp' && function_exists('imagecreatefromwebp') && !Rhymix\Framework\Image::isAnimatedWebP($source_file))
|
||||
{
|
||||
$source = @imagecreatefromwebp($source_file);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,6 +47,23 @@ class Image
|
|||
return $frames > 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a file is an animated WebP.
|
||||
*
|
||||
* @param string $filename
|
||||
* @return bool
|
||||
*/
|
||||
public static function isAnimatedWebP(string $filename): bool
|
||||
{
|
||||
if (!$fp = @fopen($filename, 'rb'))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
$buff = fread($fp, 64);
|
||||
fclose($fp);
|
||||
return preg_match('/^RIFF....WEBPVP8X[\x00-\xff]{14}ANIM/s', $buff) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get image information
|
||||
*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue