swissup/module-webp

将图片转换为webp格式的Magento2模块

安装: 153

依赖: 1

建议者: 0

安全: 0

星标: 0

关注者: 4

分支: 0

开放问题: 0

类型:magento2-module

1.0.2 2024-03-21 15:41 UTC

This package is auto-updated.

Last update: 2024-09-21 16:41:06 UTC


README

这是一个用于metapackage的magento2模块。

安装

对于客户

有几种方法可以为客户安装此扩展

  1. 如果您在Magento的Marketplace购买了产品 - 使用Marketplace安装说明

  2. 否则,您有两个选择

对于维护者
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转换。它支持多种转换方法,并自动选择系统上可用的最佳方法。

该库可以使用以下方法进行转换

除了转换之外,该库还有一个用于服务转换图像的方法,我们在此处提供了如何设置自动将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