swissup / module-webp
将图片转换为webp格式的Magento2模块
1.0.2
2024-03-21 15:41 UTC
Requires
- magento/framework: >=102.0
- magento/module-catalog: >=103.0
- rosell-dk/webp-convert: ^2.9
- swissup/module-core: ^1.12.18
Suggests
- magestyapps/module-web-images: This extension for Magento 2 allows uploading SVG and WebP images (composer require magestyapps/module-web-images)
This package is auto-updated.
Last update: 2024-09-21 16:41:06 UTC
README
这是一个用于metapackage的magento2模块。
安装
对于客户
有几种方法可以为客户安装此扩展
-
如果您在Magento的Marketplace购买了产品 - 使用Marketplace安装说明
-
否则,您有两个选择
对于维护者
cd <magento_root> composer config repositories.swissup composer https://docs.swissuplabs.com/packages/ composer require swissup/module-webp --prefer-source --ignore-platform-reqs bin/magento module:enable Swissup_Webp Swissup_Core bin/magento setup:upgrade bin/magento setup:di:compile
使用方法
检查可用的webp转换器
在图像转换之前,您需要检查是否已有某些转换器可用。工具cwebp是转换中最有用的工具。
bin/magento swissup:webp:check -a +-----------+-----------------------+ | Converter | Path | +-----------+-----------------------+ | imagick | imagick PHP extension | | gd | gd PHP extension | +-----------+-----------------------+
使用PHP将JPEG & PNG转换为WebP
此扩展使您能够使用PHP进行webp转换。它支持多种转换方法,并自动选择系统上可用的最佳方法。
该库可以使用以下方法进行转换
- cwebp(通过
exec
调用执行cwebp二进制文件) - vips(使用Vips PHP扩展)
- imagick(使用Imagick PHP扩展)
- gmagick(使用Gmagick PHP扩展)
- imagemagick(通过
exec
调用执行imagemagick二进制文件) - graphicsmagick(通过
exec
调用执行graphicsmagick二进制文件) - ffmpeg(通过
exec
调用执行ffmpeg二进制文件) - wpc(使用WebPConvert Cloud Service - 基于此库的开源PHP webp转换器)
- ewww(使用ewww云转换器(1美元启动费,然后免费转换webp))
- gd(使用Gd PHP扩展)
除了转换之外,该库还有一个用于服务转换图像的方法,我们在此处提供了如何设置自动将webp图像服务到支持webp的浏览器的解决方案的说明。
Magento 2至少有一个合理的系统要求,并且符合我们的需求。它是Gd PHP扩展。
使用此命令将产品图片转换为webp
bin/magento swissup:webp:convert
帮助
bin/magento swissup:webp:convert -h Description: Convert product images to webp Usage: swissup:webp:convert [options] webp:convert Options: --skip_hidden_images Do not process images marked as hidden from product page -l, --limit=LIMIT limit --limit=10 (default: 100 000) [default: 100000] -f, --filename=FILENAME filename filter --filename=1.png -h, --help Display help for the given command. When no command is given display help for the list command -q, --quiet Do not output any message -V, --version Display this application version --ansi|--no-ansi Force (or disable --no-ansi) ANSI output -n, --no-interaction Do not ask any interactive question -v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug