How to Convert .PNG to .WebP Using cwebp on Windows (No GUI Needed)
Abiruzzaman Molla

Abiruzzaman Molla @abiruzzamanmolla

About: Backend Developer +3y ( PHP | Laravel | JavaScript | Vuejs | jQuery | RESTful API | Version Control)

Location:
Dhaka
Joined:
Feb 19, 2018

How to Convert .PNG to .WebP Using cwebp on Windows (No GUI Needed)

Publish Date: Jul 17
0 0

🎯 WebP is the future — smaller size, better quality, faster websites.

In this quick guide, you'll learn how to install cwebp on Windows and batch convert .png images to .webp using just PowerShell.


🛠 Step 1: Download WebP Tools for Windows

Download the latest pre-built binaries from Google's official storage:

👉 https://storage.googleapis.com/downloads.webmproject.org/releases/webp/index.html

Choose the zip file matching your system, like:


libwebp-1.3.2-windows-x64.zip

Enter fullscreen mode Exit fullscreen mode

📂 Step 2: Extract the ZIP and Set the PATH

  1. Extract the ZIP to a location like:
C:\www\test\libwebp-build

Enter fullscreen mode Exit fullscreen mode
  1. Inside the folder, you'll find:
C:\www\test\libwebp-build\bin\cwebp.exe

Enter fullscreen mode Exit fullscreen mode
  1. Now add this path to your system's Environment Variables:
  2. Search for Environment Variables in Windows Start
  3. Edit the System Path variable
  4. Add:
  C:\www\test\libwebp-build\bin
Enter fullscreen mode Exit fullscreen mode
  1. Restart VS Code or your terminal

✅ Step 3: Verify the Installation

Open your terminal and run:

cwebp -version
Enter fullscreen mode Exit fullscreen mode

Output should look something like:

1.6.0
libsharpyuv: 0.4.2
Enter fullscreen mode Exit fullscreen mode

🔄 Step 4: Convert All .png Files to .webp in a Folder

Navigate to the folder where your .png files are. For example:

cd C:\www\wsus\dir_name\public\website\images
Enter fullscreen mode Exit fullscreen mode

Then run this one-liner in PowerShell:

Get-ChildItem -Filter *.png | ForEach-Object {
    $out = "$($_.DirectoryName)\$($_.BaseName).webp"
    cwebp $_.FullName -q 85 -o $out
}
Enter fullscreen mode Exit fullscreen mode

✅ This will:

  • Convert every .png file in the folder to .webp
  • Use 85% quality
  • Output the .webp file in the same folder

📁 (Optional) Output to a Subfolder

Want to keep .webp files separate? Use this:

$outputFolder = "webp_output"
New-Item -ItemType Directory -Force -Path $outputFolder

Get-ChildItem -Filter *.png | ForEach-Object {
    $out = Join-Path -Path $outputFolder -ChildPath "$($_.BaseName).webp"
    cwebp $_.FullName -q 85 -o $out
}
Enter fullscreen mode Exit fullscreen mode

🧪 Extra: Check if cwebp is recognized

where cwebp
Enter fullscreen mode Exit fullscreen mode

If the command returns a valid path, you’re good. Otherwise, check your PATH again.


🛠 If It Doesn't Work in PowerShell 7

Sometimes PowerShell 7 (pwsh) doesn't refresh your PATH immediately.
Solution: add it manually to your PowerShell profile:

notepad $PROFILE
Enter fullscreen mode Exit fullscreen mode

Then add this line:

$env:Path += ";C:\www\test\libwebp-build\bin"
Enter fullscreen mode Exit fullscreen mode

Save and restart terminal.


🎉 Done!

You just built a zero-GUI image optimization workflow on Windows.
You’re now officially in the WebP club 😎

If this helped you — leave a ❤️, bookmark it, or share with a fellow dev!


🔗 Useful Links

Comments 0 total

    Add comment