A simple batch converter that turns all PNG files in a folder into optimised WebP images using ImageMagick. Great for quickly shrinking PNG assets for web use while keeping your originals intact.
Features
- Converts all PNG files in a folder to WebP in one go
- Configurable output quality (default 80)
- Reports file size savings for each conversion
- Optional `-DeleteOriginals` flag to remove source PNGs after conversion
- Outputs WebP files alongside the originals (same folder)
Usage
Convert all PNGs in the current folder with default quality (80)
Convert-PNGtoWebp.ps1
Specify a folder and custom quality
Convert-PNGtoWebp.ps1 -Folder "C:\Images" -Quality 90
Delete originals after successful conversion
Convert-PNGtoWebp.ps1 -DeleteOriginals
Requirements
- Windows with PowerShell 5.1 or later (included with Windows 10/11)
- ImageMagick — free, open-source image toolkit
Installing ImageMagick
- Download the installer from [https://imagemagick.org/script/download.php#windows](https://imagemagick.org/script/download.php#windows) — choose the top “Win64 dynamic” `.exe` installer.
- Run the installer. On the “Select Additional Tasks” screen, make sure “Add application directory to your system path” is checked.
- Restart any open terminal/PowerShell windows.
- Verify by running: `magick –version`
Running PowerShell Scripts
If you haven’t run PowerShell scripts before, you may need to allow it once. Open PowerShell as Administrator and run:
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
Then navigate to the folder containing the script and run it.
Adding the Script to Your PATH (Optional)
For convenience, you can add the folder containing the script to your system PATH so you can run it from any directory:
- Press Win + S and search for “Environment Variables”
- Click “Edit the system environment variables”
- Click Environment Variables at the bottom
- Under User variables, select Path and click Edit
- Click New and paste the full path to the folder where you saved the script (e.g. `C:\Scripts`)
- Click OK on all dialogs
- Restart any open terminal windows
You can now run `Convert-PNGtoWebp.ps1` from anywhere without navigating to the script’s folder first.
Free download — if you find it useful, consider supporting development