From: Alexander Ebert Date: Tue, 15 Jun 2021 13:47:53 +0000 (+0200) Subject: Helper method to check for WebP support X-Git-Tag: 5.4.0_Beta_2~10^2~2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=cecb02dee775af36b6491e696356dfa8b66697e7;p=GitHub%2FWoltLab%2FWCF.git Helper method to check for WebP support --- diff --git a/wcfsetup/install/files/lib/system/image/adapter/GDImageAdapter.class.php b/wcfsetup/install/files/lib/system/image/adapter/GDImageAdapter.class.php index 2bea38d6a0..674cf649bb 100644 --- a/wcfsetup/install/files/lib/system/image/adapter/GDImageAdapter.class.php +++ b/wcfsetup/install/files/lib/system/image/adapter/GDImageAdapter.class.php @@ -13,7 +13,7 @@ use wcf\util\StringUtil; * @license GNU Lesser General Public License * @package WoltLabSuite\Core\System\Image\Adapter */ -class GDImageAdapter implements IImageAdapter +class GDImageAdapter implements IImageAdapter, IWebpImageAdapter { /** * active color @@ -613,4 +613,12 @@ class GDImageAdapter implements IImageAdapter { return \function_exists('gd_info'); } + + /** + * @inheritDoc + */ + public static function supportsWebp(): bool + { + return !empty(\gd_info()['WebP Support']); + } } diff --git a/wcfsetup/install/files/lib/system/image/adapter/IWebpImageAdapter.class.php b/wcfsetup/install/files/lib/system/image/adapter/IWebpImageAdapter.class.php new file mode 100644 index 0000000000..5fbcc7236f --- /dev/null +++ b/wcfsetup/install/files/lib/system/image/adapter/IWebpImageAdapter.class.php @@ -0,0 +1,21 @@ + + * @package WoltLabSuite\Core\System\Image\Adapter + * @since 5.4 + */ +interface IWebpImageAdapter extends IImageAdapter +{ + /** + * Reports the ability to create and process WebP images. + */ + public static function supportsWebp(): bool; +} diff --git a/wcfsetup/install/files/lib/system/image/adapter/ImagickImageAdapter.class.php b/wcfsetup/install/files/lib/system/image/adapter/ImagickImageAdapter.class.php index afedf3d3c9..bd62d899e8 100644 --- a/wcfsetup/install/files/lib/system/image/adapter/ImagickImageAdapter.class.php +++ b/wcfsetup/install/files/lib/system/image/adapter/ImagickImageAdapter.class.php @@ -14,7 +14,7 @@ use wcf\util\StringUtil; * @license GNU Lesser General Public License * @package WoltLabSuite\Core\System\Image\Adapter */ -class ImagickImageAdapter implements IImageAdapter +class ImagickImageAdapter implements IImageAdapter, IWebpImageAdapter { /** * active color @@ -527,4 +527,12 @@ class ImagickImageAdapter implements IImageAdapter { return \version_compare($version, '6.3.6') >= 0; } + + /** + * @inheritDoc + */ + public static function supportsWebp(): bool + { + return \in_array('WEBP', \Imagick::queryFormats()); + } }