Converting JPG/JPEG and PNG to WebP
Google have a tool to easily convert images to WebP
This guide is written for Windows 11, but Google also have tools for other platforms
Initial steps
1) Go to https://developers.google.com/speed/webp/download [↗]
2) Click on Download for Windows
3) Extract the file you downloaded and store in a place you can easily navigate to, such as C:\
4) Open Terminal (PowerShell/CMD) as administrator
5) Navigate to the bin folder of the extracted files
[snippet]cd "path to bin folder"
#Example
cd c:\libwebp-1.3.0-windows-x64\bin[/snippet]
Single image convert
1) Perform Initial steps before continuing
2) Converting image, we need to define quality (0 worst - 100 best), path to images and where to save the converted images (can be same as original path)
[snippet]cwebp.exe -q [quality number] [path to the image you want to convert] -o [path to save the converted image]
#Example
cwebp.exe -q 90 "C:\convert to webp\original\20210407_1001_606d608936d92.png" -o "C:\convert to webp\converted\20210407_1001_606d608936d92.webp"[/snippet]
3) If you navigate to the converted folder, you'll now find the webp file
4) By changing filename, you can covert more files
Batch convert
1) Perform Initial steps before continuing, but for batch PowerShell is required
2) Now you want to enter below, Shift + Enter allows you to go to new line without executing
[snippet]$dir = "[path to the folder of the images you want to convert]"
$images = Get-ChildItem $dir
foreach ($img in $images) {
$outputName = $img.DirectoryName + "\" + $img.BaseName + ".webp"
.\cwebp.exe $img.FullName -o $outputName
}
#Example
$dir = "C:\convert to webp\original"
$images = Get-ChildItem $dir
foreach ($img in $images) {
$outputName = $img.DirectoryName + "\" + $img.BaseName + ".webp"
.\cwebp.exe $img.FullName -o $outputName
}[/snippet]
3) Now the files have been converted to WebP
Tags: #WebP #PNG #JPG #JPEG #ConvertJPGtoWebP