我想制作一个在Squoosh中导入批量图像的程序,但我不知道如何使用Squoosh/CLI调整大小。
在 Squoosh/CLI
--help
上的 --resize
选项中,我有:--resize [config]
而且我不知道我要在[]中输入什么。
您应该在
--resize
选项之后传递一个带有键值对的对象。
你会得到这样的东西:
--resize "{'enabled':true,'width':400,'method':'lanczos3','fitMethod':'stretch','premultiply':true,'linearRGB':true}"
我建议您将选项对象用双引号引起来,同时将键值对用单引号引起来。似乎某些键隐式需要单引号,并且用双引号引起来时将不起作用。就我个人而言,我在启用“宽度”和“高度”选项时遇到了这个问题。
--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