* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @package WoltLabSuite\Core\System\Image\Adapter
*/
-class GDImageAdapter implements IImageAdapter
+class GDImageAdapter implements IImageAdapter, IWebpImageAdapter
{
/**
* active color
{
return \function_exists('gd_info');
}
+
+ /**
+ * @inheritDoc
+ */
+ public static function supportsWebp(): bool
+ {
+ return !empty(\gd_info()['WebP Support']);
+ }
}
--- /dev/null
+<?php
+
+namespace wcf\system\image\adapter;
+
+/**
+ * A WebP capable image adapter exposes a helper method to verify the
+ * support for the creation and processing of WebP images.
+ *
+ * @author Alexander Ebert
+ * @copyright 2001-2021 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @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;
+}
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @package WoltLabSuite\Core\System\Image\Adapter
*/
-class ImagickImageAdapter implements IImageAdapter
+class ImagickImageAdapter implements IImageAdapter, IWebpImageAdapter
{
/**
* active color
{
return \version_compare($version, '6.3.6') >= 0;
}
+
+ /**
+ * @inheritDoc
+ */
+ public static function supportsWebp(): bool
+ {
+ return \in_array('WEBP', \Imagick::queryFormats());
+ }
}