如何在 Squoosh CLI 中使用调整大小

问题描述 投票:0回答:2

我想制作一个在Squoosh中导入批量图像的程序,但我不知道如何使用Squoosh/CLI调整大小。

Squoosh/CLI

--help
上的
--resize
选项中,我有:
--resize [config]

而且我不知道我要在[]中输入什么。

node.js terminal command-line-interface config bulk
2个回答
1
投票

您应该在

--resize
选项之后传递一个带有键值对的对象。 你会得到这样的东西:

--resize "{'enabled':true,'width':400,'method':'lanczos3','fitMethod':'stretch','premultiply':true,'linearRGB':true}"

我建议您将选项对象用双引号引起来,同时将键值对用单引号引起来。似乎某些键隐式需要单引号,并且用双引号引起来时将不起作用。就我个人而言,我在启用“宽度”和“高度”选项时遇到了这个问题。


0
投票

--resize
选项只有
width
height
method
premultiply
linearRGB
。所有可用选项都可以在此处找到。

这是

--resize
的定义:

{
  width: number;
  height: number;
  method: 'triangle' | 'catrom' | 'mitchell' | 'lanczos3';
  premultiply: true;
  linearRGB: true;
}

例如:

--resize "{'enabled':true,'width':400,'method':'lanczos3','fitMethod':'stretch','premultiply':true,'linearRGB':true}"

我还在此处制作了 Squoosh CLI 的完整文档:https://hub.docker.com/r/willh/squoosh-cli

如果您使用 Windows,我建议您使用 Docker 容器来运行 Squoosh CLI。您可以在这里看到我的实现:willh/squoosh-cli

最新问题
© www.soinside.com 2019 - 2024. All rights reserved.