LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

cwebp

Google WebP image encoder

TLDR

Convert an image to WebP format
$ cwebp [input.png] -o [output.webp]
copy
Convert with specific quality (0-100)
$ cwebp -q [80] [input.jpg] -o [output.webp]
copy
Create lossless WebP
$ cwebp -lossless [input.png] -o [output.webp]
copy
Resize during conversion
$ cwebp -resize [800] [600] [input.jpg] -o [output.webp]
copy
Convert with alpha channel preservation
$ cwebp -alpha_q [100] [input.png] -o [output.webp]
copy
Use near-lossless compression
$ cwebp -near_lossless [60] [input.png] -o [output.webp]
copy
Maximum compression effort (slowest, smallest)
$ cwebp -m 6 -q [80] [input.jpg] -o [output.webp]
copy
Use a preset tuned for photos
$ cwebp -preset photo -q [80] [input.jpg] -o [output.webp]
copy

SYNOPSIS

cwebp [options] inputfile **-o** outputfile.webp

DESCRIPTION

cwebp is Google's encoder for the WebP image format. WebP provides superior compression compared to JPEG and PNG while supporting both lossy and lossless modes, as well as animation and alpha transparency.The encoder accepts PNG, JPEG, TIFF, and WebP inputs (animated PNG and WebP are not supported). For lossy compression, the -q parameter controls the quality-size tradeoff. For lossless, the -z parameter controls compression effort. Using -o - sends the encoded output to stdout.WebP is widely supported in web browsers and offers 25-34% smaller file sizes than JPEG at equivalent quality. The lossless mode typically achieves 26% smaller files than PNG.

PARAMETERS

-o FILE

Output WebP file path.
-q QUALITY
Compression quality (0-100, default 75). Higher is better quality.
-lossless
Encode image losslessly.
-near_lossless LEVEL
Near-lossless preprocessing (0-100, default 100 = no preprocessing; 60 is typical). Triggers lossless mode.
-alpha_q QUALITY
Alpha channel quality (0-100, default 100 = lossless alpha).
-resize WIDTH HEIGHT
Resize to the given dimensions. A value of 0 for one dimension preserves the aspect ratio.
-crop X Y W H
Crop the input image to the rectangle at (X,Y) with width W and height H.
-preset NAME
Preset: default, photo, picture, drawing, icon, text. Must appear before other options.
-m METHOD
Compression method (0-6, default 4; higher is slower but produces smaller files).
-z LEVEL
Lossless compression preset (0-9, 0 fastest / 9 slowest; a good default is 6).
-exact
Preserve RGB values in fully transparent areas (lossless only).
-mt
Use multi-threading if available.
-v
Verbose output.

CAVEATS

Very high quality settings may produce files larger than the source. Some older software doesn't support WebP. Lossy WebP introduces artifacts similar to JPEG. Near-lossless mode modifies pixels slightly for better compression.

HISTORY

WebP was developed by Google and released in 2010, based on the VP8 video codec. The cwebp encoder is part of the libwebp reference implementation. WebP achieved widespread browser support by 2020 and is recommended for web image optimization.

SEE ALSO

dwebp(1), gif2webp(1), cjpeg(1), convert(1)

Copied to clipboard
Kai