WebP images
| WebP on a page | |
| Convert with cwebp | |
| How much smaller | |
| Convert a folder on Linux | |
| Convert a folder on Windows |
WebP is an image format by Google that stores the same picture in fewer bytes than JPEG or PNG, and smaller images make pages load faster. All current browsers show it. The conversions on this page were run on 26 October 2026 with cwebp 1.5.0 in a Debian 13 container, on two images of this site.
WebP on a page
Keep the JPEG or PNG and add the WebP next to it with the picture element. A browser takes the first source it can show, and an old one falls back to the img:
<picture> <source type="image/webp" srcset="img/logo.webp"> <img src="img/logo.jpg" alt="Logo"> </picture>
Convert with cwebp
cwebp is the converter of the WebP library. On Debian and Ubuntu:
sudo apt install webp
For Windows and macOS download it from developers.google.com/speed/webp/download. Convert one file with quality 80 of 100:
cwebp -q 80 photo.jpg -o photo.webp
For screenshots, drawings and other images with flat colours, lossless compression is usually better:
cwebp -lossless screenshot.png -o screenshot.webp
How much smaller
A JPEG screenshot of a control panel and a PNG screenshot of a phpinfo page, in bytes:
ls -l --block-size=1 *.png *.jpg *.webp | awk '{print $5, $9}'
58557 beget_email_00104.jpg 27216 beget_email_00104.webp 23042 phpinfo_00100-lossless.webp 83528 phpinfo_00100.png 66278 phpinfo_00100.webp
| Image | Original | WebP | Saved |
|---|---|---|---|
| JPEG, -q 80 | 58,557 | 27,216 | 54% |
| PNG, -q 80 | 83,528 | 66,278 | 21% |
| PNG, -lossless | 83,528 | 23,042 | 72% |
The PNG screenshot shrank three times more without loss than with it: flat areas of the same colour are what lossless WebP stores best.
Convert a folder on Linux
A loop in bash writes a WebP next to every PNG and JPEG of the current folder:
for f in *.png *.jpg; do cwebp -quiet -q 80 "$f" -o "${f%.*}.webp" done
${f%.*} is the file name without its extension, and -quiet leaves out the statistics cwebp prints for every file.
Convert a folder on Windows
Put cwebp.exe and the images into one folder and create a PowerShell script there:
notepad converter.ps1
foreach ($img in Get-ChildItem . -File | Where-Object { $_.Extension -in '.png', '.jpg' }) { # the WebP goes next to the original, with the same name $outputName = Join-Path $img.DirectoryName ($img.BaseName + ".webp") # more options: https://developers.google.com/speed/webp/docs/cwebp .\cwebp.exe -q 80 $img.FullName -o $outputName }
Run it from that folder:
.\converter.ps1
or right-click the file and choose Run with PowerShell. If Windows refuses to run scripts, allow scripts for your user once with Set-ExecutionPolicy -Scope CurrentUser RemoteSigned.
Article authors: Andrei Olegovich, Klavdiya Kondakova