@frostoven/squoosh-cli

中文文档
0.9.1发布于 2024/04/30Apache-2.0ES Module近 30 天下载 2594

斯库什的CLI

中文使用文档
文档目录3 节
  1. 安装
  2. 使用量
  3. 自动优化器

斯克沃什 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

版本与发布记录

@frostoven/squoosh-cli 共发布 6 个版本,首次发布于 2023/05/20;过去 12 个月发布了 0 个版本。

版本发布日期距今
0.9.1latest2024/04/302 年前
0.9.02024/04/302 年前
0.8.12024/04/292 年前
0.7.62023/09/273 年前
0.7.52023/05/203 年前
0.7.42023/05/203 年前

关于 @frostoven/squoosh-cli 的常见问题

@frostoven/squoosh-cli 是什么?

斯库什的CLI

如何安装 @frostoven/squoosh-cli?

在项目目录运行 npm install @frostoven/squoosh-cli,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 squoosh-cli、squoosh-cli-debug,可以用 npx squoosh-cli 直接运行。

@frostoven/squoosh-cli 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/frostoven__squoosh-cli 是否存在。

@frostoven/squoosh-cli 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@frostoven/squoosh-cli 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=16.0.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@frostoven/squoosh-cli 可以商用吗?

@frostoven/squoosh-cli 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@frostoven/squoosh-cli 的下载量有多少?

根据 npm 官方下载统计,@frostoven/squoosh-cli 在 2026/10/16 – 2026/11/14 这 30 天内被下载 2,594 次,日均约 86 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@frostoven/squoosh-cli 还在维护吗?

最新版本 0.9.1 发布于 2024/04/30(2 年前);至今共发布 6 个版本,其中过去 12 个月发布了 0 个;首次发布于 2023/05/20。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。