cwebp is a command-line tool used to compress images in the WebP format. It is part of the WebP image format library, developed by Google.
cwebp is included in the WebP image format library, which can be downloaded from the official WebP website.
cwebp [options] input_file -o output_file.webp
-q <float>
: Set the compression quality factor (0-100, default: 75).-m <int>
: Set the maximum size of the output file (in bytes).-lossless
: Enable lossless compression mode.-alpha_q <int>
: Set the transparency-compression quality factor (0-100, default: 100).-alpha_method <int>
: Set the transparency-compression method (0=fast, 1=default, 2=slow).-h
: Display help information.Convert a PNG image to lossy WebP format with default settings:
cwebp input.png -o output.webp
Convert a PNG image to lossless WebP format with custom compression quality:
cwebp -lossless -q 90 input.png -o output.webp
Convert a PNG image with transparency to lossy WebP format with custom settings:
cwebp -q 80 -alpha_q 90 -alpha_method 1 input.png -o output.webp