斯克沃什 CLI
Squoosh CLI是一种实验方法 运行所有你认识的解码器 斯库什语Name 使用 web app在命令行上的网络应用程序 网易大会. Squoosh CLI 使用工人池来平行加工 图像。 这样您就可以同时对许多图像应用同样的代码.
Squoosh CLI 目前不是镇上最快的图像压缩工具 并不打算成为。 但是,它足够快 压缩许多图像 足够快的一次.
请注意,这是叉子 原始图书馆,已经 从退休以来 这个叉子继续工作,并有一些错误修正.
安装
Squoosh CLI 可以从命令行直接使用而不使用 npx数字 :
$ npx @frostoven/squoosh-cli <options...>
当然,您也可以安装 Squoosh CLI :
$ npm i -g @frostoven/squoosh-cli
$ squoosh-cli <options...>
使用量
Usage: squoosh-cli [options] <files...>
Options:
-d, --output-dir <dir> Output directory (default: ".")
-s, --suffix <suffix> Append suffix to output files (default: "")
-c, --max-concurrent-files <count> Amount of files to process at once (defaults to your CPU core count)
--max-optimizer-rounds <rounds> Maximum number of compressions to use for auto optimizations (default: "6")
--optimizer-butteraugli-target <butteraugli distance> Target Butteraugli distance for auto optimizer (default: "1.4")
--resize [config] Resize the image before compressing
--quant [config] Reduce the number of colors used (aka. paletting)
--rotate [config] Rotate image
--mozjpeg [config] Use MozJPEG to generate a .jpg file with the given configuration
--webp [config] Use WebP to generate a .webp file with the given configuration
--avif [config] Use AVIF to generate a .avif file with the given configuration
--jxl [config] Use JPEG-XL to generate a .jxl file with the given configuration
--wp2 [config] Use WebP2 to generate a .wp2 file with the given configuration
--oxipng [config] Use OxiPNG to generate a .png file with the given configuration
-V, --version Output associated version numbers
-h, --help Display help for command
每个的默认值 config 选项可以在 codecs.ts 文件编号 defaultEncoderOptions。每个未指定值都将使用此处指定的默认值. 这里需要更好的文件.
自动优化器
Squoosh CLI有一个 实验 尽可能压缩图像的自动优化器,试图击中特定 黄油 目标值。 巴特劳格利的目标值越高,可以引进的文物就越多.
通过使用“自动”作为配置对象,您可以使用自动优化器.
$ npx @frostoven/squoosh-cli --wp2 auto test.png