Skip to content

Instantly share code, notes, and snippets.

@frozenex
Last active January 14, 2024 02:04
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save frozenex/4388145545163cf85e94d07cb18fe931 to your computer and use it in GitHub Desktop.
Save frozenex/4388145545163cf85e94d07cb18fe931 to your computer and use it in GitHub Desktop.
Bulk convert images to webp format using cwebp library in windows
# Copy this file to any directory containing images & then run this script in powershell
# Get all png images in the current directory & convert it to webp format
$images = Get-ChildItem -Path (Get-Location) -Filter *.png
foreach ($image in $images) {
$fileName = $image.DirectoryName + "\" + $image.BaseName + ".webp"
cwebp.exe -q 80 $image.FullName -o $fileName
}
@Sparking2
Copy link

I'll probably add the recursive property because this script only works with images/folders that are in the same level than te script

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment