Created
February 21, 2024 21:58
-
-
Save byBretema/93af961c61b55f6442b6b3d66bdf1414 to your computer and use it in GitHub Desktop.
replace png images in all subfolders by webp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# install cwebp from: https://developers.google.com/speed/webp/docs/precompiled, and add it to $env:PATH | |
# 1- Conver png to web | |
(Get-ChildItem . -Recurse -File) | ForEach-Object { $src = "$($_.DirectoryName)\$($_.Name)"; if ($src.EndsWith(".png")) { $dst = $src.Replace(".png", ".webp"); cwebp -q 60 -o $dst $_; } } | |
# 2- Cleanup converted png files | |
(Get-ChildItem . -Recurse -File) | ForEach-Object { $src = "$($_.DirectoryName)\$($_.Name)"; if ($src.EndsWith(".png")) { Remove-Item $_ } } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment