@343dev/optimizt

中文文档
13.0.0发布于 2026/06/27MITES Module构建来源已验证近 30 天下载 1.3万

CLI image optimization tool

原始使用文档
文档目录19 节
  1. Rationale
  2. Usage
  3. Command Line Flags
  4. Usage Examples
  5. Differences Between Lossy and Lossless
  6. Lossy (Default)
  7. Lossless ( --lossless flag)
  8. Configuration
  9. Troubleshooting
  10. Errors like “spawn guetzli ENOENT”.
  11. Development
  12. Docker
  13. Pre-Built Image
  14. Manual Build
  15. Run Container
  16. Integrations
  17. Articles
  18. Credits
  19. Other projects

@343dev/optimizt

Optimizt logo: OK hand sign with Mona Lisa image between the fingers

NPM Downloads npm Docker

Optimizt is a command-line tool that helps prepare images for the web.

It can compress PNG, JPEG, GIF, and SVG lossy or lossless, and create AVIF and WebP versions for raster images.

Rationale

As frontend developers, we have to care about pictures: compress PNG and JPEG, remove useless parts of SVG, create AVIF and WebP for modern browsers, and so on. One day, we got tired of using a bunch of apps for that, and created one tool that does everything we want.

Usage

Install:

npm install -g @343dev/optimizt

Optimize!

optimizt path/to/picture.jpg

Command Line Flags

  • --avif — create AVIF versions of images.
  • --webp — create WebP versions of images.
  • -f, --force — recreate AVIF and WebP versions even if they already exist.
  • -l, --lossless — optimize losslessly instead of lossily.
  • -v, --verbose — show detailed output (e.g. skipped files).
  • -c, --config — use a custom configuration file instead of the default.
  • -o, --output — write results to the specified directory.
  • -p, --prefix — add prefix to optimized file names.
  • -s, --suffix — add suffix to optimized file names.
  • -V, --version — display the tool version.
  • -h, --help — show help message.

Usage Examples

# optimize a single image
optimizt path/to/picture.jpg

# optimize multiple images losslessly
optimizt --lossless path/to/picture.jpg path/to/another/picture.png

# recursively create AVIF and WebP versions for all images in a directory
optimizt --avif --webp path/to/directory

# recursively optimize JPEG files in the current directory
find . -iname \*.jpg -exec optimizt {} +

Differences Between Lossy and Lossless

Lossy (Default)

Provides the best balance between file size reduction and minimal visual quality loss.

Lossless (--lossless flag)

  • AVIF/WebP: Uses lossless compression.
  • PNG/JPEG/GIF: Maximizes image quality at the expense of larger file sizes.
  • SVG: Settings are identical in both modes.

Configuration

Image processing leverages:

[!NOTE] In Lossless mode for JPEG, Guetzli is used. Repeated optimization may degrade visual quality.

Default settings are defined in .optimiztrc.cjs, which includes all supported parameters. Disable any parameter by setting it to false.

When using --config path/to/.optimiztrc.cjs, the specified configuration file will be used. If no --config is provided, Optimizt searches recursively from the current directory upward for .optimiztrc.cjs. If none is found, defaults are applied.

Troubleshooting

Errors like “spawn guetzli ENOENT”.

Ensure the ignore-scripts npm option is disabled. Details: funbox/optimizt/issues/9.

Development

After cloning the repository, enable Git hooks once:

npm run enable-git-hooks

This configures Git to use the versioned hooks from the .githooks directory.

Docker

Pre-Built Image

# pull latest
docker pull 343dev/optimizt

# pull specific version
docker pull 343dev/optimizt:9.0.2

Manual Build

# clone repository
git clone https://github.com/343dev/optimizt.git
cd optimizt

# build image
docker build --tag 343dev/optimizt .

Alternatively:

# build directly from GitHub
# ignores .dockerignore (see: https://github.com/docker/cli/issues/2827)
docker build --tag 343dev/optimizt https://github.com/343dev/optimizt.git

Run Container

# mount current directory to /src in the container
docker run --rm --volume $(pwd):/src 343dev/optimizt --webp ./image.png

Integrations

Optimizt works seamlessly with:

Articles

Credits

Cute picture for the project was made by Igor Garybaldi.

Other projects

  • 📦 harold — CLI tool that compares frontend project bundle sizes between snapshots
  • 🐳 jailbot — Docker container wrapper with automatic filesystem path mounting
  • 📝 markdown-lint — Markdown code style linter based on Prettier, Remark, and Typograf
  • 🔤 languagetool-node — CLI spell and grammar checker powered by LanguageTool

版本与发布记录

@343dev/optimizt 共发布 18 个版本,首次发布于 2023/07/10;过去 12 个月发布了 4 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
13.0.0latest2026/06/274 个月前
12.1.12026/01/0210 个月前
12.1.02025/12/2410 个月前
12.0.02025/12/2310 个月前
11.0.02025/05/041.5 年前
10.0.02024/10/282 年前

关于 @343dev/optimizt 的常见问题

@343dev/optimizt 是什么?

CLI image optimization tool

如何安装 @343dev/optimizt?

在项目目录运行 npm install @343dev/optimizt,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 optimizt,可以用 npx optimizt 直接运行。

@343dev/optimizt 支持 TypeScript 吗?

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

@343dev/optimizt 支持 ESM 还是 CommonJS?

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

@343dev/optimizt 需要什么版本的 Node.js?

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

@343dev/optimizt 可以商用吗?

@343dev/optimizt 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@343dev/optimizt 的下载量有多少?

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

@343dev/optimizt 还在维护吗?

最新版本 13.0.0 发布于 2026/06/27(4 个月前);至今共发布 18 个版本,其中过去 12 个月发布了 4 个;首次发布于 2023/07/10。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。