How to convert multiple images to webp format on Windows 10


It's been a while since I last added an article to this site.  So I thought I would write about a recent challenge I had.

 

The challenge was to convert many .jpg's, .gif's & .png's to .webp. Why webp? Well webp is an image format that supports lossy and lossless compression.  It's great for the web & for speeding up page load times!

 

There are online tools to help you convert an image from other formats to webp. Unfortunately, a lot of these tools have limits and want to charge you.  I found myself in a situation where I had to convert hundreds of images recently and decided to find the best solution to quickly convert folders full of images.

 

Google provide a tool to use which can convert the images for you.

  • Visit Google's download page to see a list of downloads.
  • Download the latest Windows version.  At this time it is 'libwebp-1.2.1-windows-x64.zip'
  • Extract the files to your C:\ drive so that you have a folder called c:\libwebp-1.2.1-windows-x64.

 

To convert an image is as easy as opening up Powershell (as an administrator) and running the command.

cwebp -q 80 image.png -o image.webp

If you have a folder full of images and don't want to have to do them one by one.  Copy this script into your powershell and update the $imageFolder variable.

 

   $imageFolder = "C:\my-website\my-images"
    
   $images = Get-ChildItem $imageFolder
    
   foreach ($img in $images) {
  
   $outputName = $img.DirectoryName + "\" + $img.BaseName + ".webp"
  
   C:\libwebp-1.2.1-windows-x64\bin\cwebp.exe $img.FullName -o $outputName
}

Comment