Skip to content

CLI Usage

zipax-bot edited this page Aug 11, 2026 · 2 revisions

CLI 使用

zipax-cli 是压缩核心的命令行入口,用于测试与自动化场景。它与桌面应用共享同一套压缩逻辑(zipax-core)。

基本用法

cd zipax-cross
# 查看帮助
cargo run -q -p zipax-cli -- --help

规划(plan)

预览压缩效果,不实际写文件:

cargo run -q -p zipax-cli -- plan photo.jpg
cargo run -q -p zipax-cli -- plan photo.png --overwrite --output-format webp

压缩(compress)

JPEG

# 默认质量
cargo run -q -p zipax-cli -- compress photo.jpg --level 4
# 转换为 AVIF
cargo run -q -p zipax-cli -- compress photo.jpg --output-format avif --level 4
# 限制尺寸
cargo run -q -p zipax-cli -- compress photo.jpg --max-width 128 --max-height 128

PNG

cargo run -q -p zipax-cli -- compress photo.png --level 4
# 转换为 WebP 并限制目标大小 500KB
cargo run -q -p zipax-cli -- compress photo.png --output-format webp --target-size-kb 500

多文件批处理

cargo run -q -p zipax-cli -- compress a.png b.png --output-format webp

常用参数

参数 说明
--level N 质量等级 1–6(默认 3)
--output-format <fmt> 输出格式:jpeg / png / webp / avif
--max-width / --max-height 尺寸限制(像素)
--target-size-kb N 目标文件大小(KB)
--overwrite 覆盖原文件

测试

cargo test

回到 Home · English: CLI Usage

Clone this wiki locally