You are using an outdated browser. For a faster, safer browsing experience, upgrade for free today.

I wanted a quick and efficient way to convert all of my site's images into webp format, but couldn't find anything for Windows that tickled my fancy, so I wrote a quick script to do the heavy lifting for me. 

The first thing that you'll want to do is download the webp library from Google. As of the time of writing, the latest version is 1.1.0 and that can be found here. The library is pre-compiled, so you don't have to do anything but download and extract the files from the archive. 

The function that I wrote is pretty straightforward. Here is a brief explanation of the command itself & it's input parameters:

Convert-Images <input_directory> <output directory> <quality (0-100)>
The output directory is where you want to put the images. The sub-directory that the script entered while traversing the structure will be appended to the end of the output directory. 
Lastly, we have a simple quality value ranging from 0 to 100. The lower the quality the smaller the converted file will be, but the quality will also be lowered. 
For my purposes, I used the following command:
Convert-Images "D:/DeleteMe/webp/Originals/" "D:/Projects/Web/Asp.Net/MVC/Umbraco/coderPro.Web.Corp.UI/media" 85
Last, but certainly not least, here is the script:


Files magically converted.
Voila! Just as simple as that all of your old files are converted to WebP and Google PageSpeed Insights will finally shut up. 😁 If you have any questions or need any help with your programming project, please feel free to drop me a line anytime, by using our contact form.


Until next time: 

Happy scripting!