WebP images

Contents
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

ImageOriginalWebPSaved
JPEG, -q 8058,55727,21654%
PNG, -q 8083,52866,27821%
PNG, -lossless83,52823,04272%

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

Related articles
Responsive design: an adaptive menu
Beget mail: create a mailbox
Canonical page: rel=canonical
CSS
Firefox
Which hosting to choose
VPS hosting
HTTP status codes
Joomla
OpenCart
PUT vs POST
Redirects
Russian IP ranges
SEO
Element tbody not allowed as child of element table in this context
CSS test: shapes and line numbers
CSS test 2: the code blocks of this site
Website testing
A tram drawn with CSS
URL encoding
UTM tags
Telling bots from people
WebP images
Moving a website: domain and hosting
WordPress
Move a WordPress site
Yandex Metrica: goals
Yandex Mail: collect mail from other mailboxes

Search this site

Channel @aofeed Chat @aofeedchat

Contacts and cooperation:
I recommend our hosting beget.com
Write to info@aredel.com if you:
1. Want to write an article for our site or translate an article into your native language.
2. Want to place thematically relevant ads on the site.
3. Ads on my site pass maximum censorship. If you see an ad block unsuitable for school-age children, shocking or misleading - please contact us by e-mail
4. Found a mistake, inaccuracy, bug, etc. on the site. ... .......
5. Articles can be shared on social media by clicking a network icon: