基础使用
WebP简介
An image format for the Web
WebP 由Google推出的一种现代图像格式,可为Web上的图像提供卓越的无损和有损压缩。与PNG相比WebP无损图像的尺寸小26%,WebP有损图像比同等SSIM质量指数下的同类JPEG图像小25-34%, 而无损 WebP 支持透明度(也称为 alpha 通道),而额外字节数仅为 22%。对于可接受有损 RGB 压缩的情况,有损 WebP 还支持透明度,通常提供比 PNG 小三倍的文件大小。
温馨提示: 目前支持 PNG / JPEG / GIF /PNM (PGM, PPM, PAM),/ TIFF
等图片格式转换为webp格式。
官方工具
名称 | 说明 | 示例 |
---|---|---|
cwebp | 将 JPEG、PNG 或 TIFF 格式的图片编码为 WebP | cwebp [options] input_file -o output_file.webp |
dwebp | dwebp 将webp文件其解码回 PNG。 | dwebp [options] input_file.webp |
gif2webp | 将 GIF 图片转换为 WebP 格式 | gif2webp [options] input_file.gif -o output_file.webp |
img2webp | 通过一系列输入图片创建动画 WebP 文件。 | img2webp [file_options] [[frame_options] frame_file]... |
vwebp | 解压缩 WebP 文件,然后在窗口中显示该文件 | vwebp [options] input_file.webp |
webpinfo | 输出 WebP 文件的区块级结构以及基本完整性检查 | webpinfo OPTIONS INPUT |
webpmux | 从非动画形式的 WebP 图片创建动画 WebP 文件,从动画 WebP 图片中提取帧 | |
webp_quality | ||
WebP |
cwebp
基础使用
语法:cwebp [options] input_file -o output_file.webp
# 压缩图片
cwebp -m 6 -mt c:/test.png -o c:/test.webp
# 将图片转换为800宽,自动保持宽高比
cwebp -m 6 -mt -resize 800 c:/test.png -o c:/test.webp
options: