From a3bbcc7d82d060092066bc380cfcec54e8da8809 Mon Sep 17 00:00:00 2001 From: yaayakk Date: Fri, 22 Mar 2024 10:40:30 +0700 Subject: [PATCH 1/2] adjust(gd): add feature for webp --- yii/image/drivers/Kohana/Image/GD.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/yii/image/drivers/Kohana/Image/GD.php b/yii/image/drivers/Kohana/Image/GD.php index 9929543..da9b0b7 100644 --- a/yii/image/drivers/Kohana/Image/GD.php +++ b/yii/image/drivers/Kohana/Image/GD.php @@ -104,6 +104,9 @@ public function __construct($file) case IMAGETYPE_PNG: $create = 'imagecreatefrompng'; break; + case IMAGETYPE_WEBP: + $create = 'imagecreatefromwebp'; + break; } if ( ! isset($create) OR ! function_exists($create)) @@ -657,6 +660,11 @@ protected function _save_function($extension, & $quality) // Use a compression level of 9 (does not affect quality!) $quality = 9; break; + case 'webp': + // Save a PNG file + $save = 'imagewebp'; + $type = IMAGETYPE_WEBP; + break; default: throw new ErrorException(sprintf('Installed GD does not support %s images',$extension)); break; From 384dee9554bc3c2a8b0cc87c3837cb6a1f0e980e Mon Sep 17 00:00:00 2001 From: yaayakk Date: Fri, 22 Mar 2024 11:38:18 +0700 Subject: [PATCH 2/2] fix comment --- yii/image/drivers/Kohana/Image/GD.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yii/image/drivers/Kohana/Image/GD.php b/yii/image/drivers/Kohana/Image/GD.php index da9b0b7..af6cd70 100644 --- a/yii/image/drivers/Kohana/Image/GD.php +++ b/yii/image/drivers/Kohana/Image/GD.php @@ -661,7 +661,7 @@ protected function _save_function($extension, & $quality) $quality = 9; break; case 'webp': - // Save a PNG file + // Save a WEBP file $save = 'imagewebp'; $type = IMAGETYPE_WEBP; break;