← 返回 CLI 目录 抓取的
cwebp
$ cwebp 官方出品 低风险 Google · AI 能力与音视频 · BSD-3-Clause · macos / linux / windows
Google 官方 libwebp CLI 套件以 cwebp 为核心,用于将 PNG/JPEG/TIFF 图像编码为有损或无损 WebP,并配套提供解码器 dwebp、动图与 ICC/EXIF 封装工具 webpmux,以及用于检查 WebP RIFF 数据块的 webpinfo。
FCRS-1.0 综合评分
84 /100
良好 (Good)
高置信度 (实测)
零摩擦安装命令
brew install webp CLI vs MCP 选型建议 仅 CLI 可用
将网页资源编码为 WebP 及通过 webpinfo 检查 RIFF 头完全在本地执行,无需 MCP。
Agent 友好度体检单
本地探针实测证据 — 原生 JSON 输出
— 字段裁剪
✓ 无头非交互
— 支持 Dry-Run
— 只读模式开关
✓ 支持 NO_COLOR
✓ 自省/Schema 发现
— 官方 SKILL.md
实测版本
1.6.0
冷启动耗时
4 ms
退出码 (help / 非法参数)
1 / 1
NO_COLOR 无色码污染 / 无 TTY 不挂起
Yes / Safe
抓取的 --help 摘要
Usage:
cwebp [-preset <...>] [options] in_file [-o out_file]
If input size (-s) for an image is not specified, it is
assumed to be a PNG, JPEG, TIFF or WebP file.
Note: Animated PNG and WebP files are not supported.
Options:
-h / -help ............. short help
-H / -longhelp ......... long help
-q <float> ............. quality factor (0:small..100:big), default=75
-alpha_q <int> ......... transparency-compression quality (0..100),
default=100
-preset <string> ....... preset setting, one of:
default, photo, picture,
drawing, icon, text
-preset must come first, as it overwrites other parameters
-z <int> ............... activates lossless preset with given
level in [0:fast, ..., 9:slowest]
-m <int> ............... compression method (0=fast, 6=slowest), default=4
-segments <int> ........ number of segments to use (1..4), default=4
-size <int> ............ target size (in bytes)
-psnr <float> .......... target PSNR (in dB. typically: 42)
-s <int> <int> ......... input size (width x height) for YUV
-sns <int> ............. spatial noise shaping (0:off, 100:max), default=50
-f <int> ............... filter strength (0=off..100), default=60
-sharpness <int> ....... filter sharpness (0:most .. 7:least sharp), default=0
-strong ................ use strong filter instead of simple (default)
-nostrong .............. use simple filter instead of strong
-sharp_yuv ............. use sharper (and slower) RGB->YUV conversion
-partition_limit <int> . limit quality to fit the 512k limit on
the first partition (0=no degradation ... 100=full)
-pass <int> ............ analysis pass number (1..10)
-qrange <min> <max> .... specifies the permissible quality range
(default: 0 100)
-crop <x> <y> <w> <h> .. crop picture with the given rectangle
-resize <w> <h> ........ resize picture (*after* any cropping)
-resize_mode <string> .. one of: up_only, down_only, always (default)
-mt .................... use multi-threading if available
-low_memory ............ reduce memory usage (slower encoding)
-map <int> ............. print map of extra info
-print_psnr ............ prints averaged PSNR distortion
-print_ssim ............ prints averaged SSIM distortion
-print_lsim ............ prints local-similarity distortion
-d <file.pgm> .......... dump the compress FCRS-1.0 六维评分拆解
Agent 友好度 18 / 25
确定性的非交互 CLI,支持 -quiet、-o - 标准输出与 -longhelp,但缺少 JSON 输出与 --dry-run。
- Supports
-quiet,-o -, and-longhelp - No JSON output or
--dry-run
安全与权限边界 22 / 25
强制通过 -o 指定独立输出路径以保护源文件不被就地修改,且 webpinfo 为严格只读检查。
- Non-destructive to source images;
webpinfois read-only
安装与运行摩擦 14 / 15
提供 Google 官方预编译包,并覆盖 Homebrew(webp)、Linux 与 Windows。
- Available via
brew install webpand official Google downloads
能力覆盖与边际价值 13 / 15
官方参考 WebP 编码器,支持有损、-lossless、-resize、-crop 与 -metadata 精细控制。
- Official
libwebpencoder with full codec tuning
维护与来源背书 9 / 10
由 Google WebP 团队官方维护的 libwebp 参考工具,采用宽松的 BSD-3-Clause 开源协议。
- Maintained by Google WebP team
文档与可验证性 8 / 10
Google Developers 文档详尽,配合 -h/-longhelp 参数说明清晰。
- Documented at developers.google.com/speed/webp/docs/cwebp
安全边界、鉴权与放权指南
鉴权方式
无需鉴权
凭证存储位置
无需凭据;仅处理本地图像文件或标准输入输出(-o -)。
潜在副作用
只读查询 本地写入
费用与配额提示
免费,Google 出品的 BSD-3-Clause 开源二进制套件。
可复制到 CLAUDE.md / AGENTS.md 的安全护栏
# cwebp (WebP) Agent Rules - Always pass `-o <output.webp>` and `-quiet` on `cwebp` so stderr stats do not pollute logs. - Remember `cwebp` writes to a separate `-o` file and never modifies input PNG/JPEG files; use `-lossless` for UI screenshots and diagrams.
Agent 高频安全命令配方
只读查询(安全推荐)
检查 WebP 数据块与帧摘要
webpinfo -summary image.webp
在不修改文件的前提下读取 WebP 的 RIFF 结构、透明/动画标志及尺寸信息。
受控写入与预演
静默将 PNG 编码为有损 WebP
cwebp -quiet -q 80 input.png -o output.webp
以 80 质量将 input.png 转换为 output.webp,同时抑制进度输出干扰。
核心优势
- + Google 官方参考编码器,提供
-lossless、-near_lossless与-quiet模式。 - + 随包附带的
webpinfo -summary与dwebp可顺畅完成检查与解码。
注意事项与踩坑点
- !
cwebp不直接接受动态 GIF(GIF 转 WebP 需使用同套件的gif2webp)。 - ! 采用单短横线参数(
-quiet、-lossless),缺少--no-overwrite与 JSON 输出。
已验证兼容的 Agent 宿主
Claude Code Codex CLI Gemini CLI