Last active
March 1, 2022 20:56
-
-
Save Sevaarcen/739c0b3c2087ca1ef3712c3b19a8ce84 to your computer and use it in GitHub Desktop.
Bulk Convert PNG to WEBP
This file contains hidden or 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
# https://developers.google.com/speed/webp/download | |
Get-ChildItem -Path . -File -Depth 0 | ForEach-Object -Parallel { &'C:\Program Files\libwebp\bin\cwebp.exe' -q 75 "$_" -o "$([io.path]::GetFileNameWithoutExtension($_)).webp" } -ThrottleLimit 16 |
Useful flags for bulk converting
-mt
- For multi-threading, if possible.
-m
0-6
- Specify the compression method to use. This parameter controls the trade off between encoding speed and the compressed file size and quality. Possible values range from 0 to 6. Default value is 4. When higher values are used, the encoder will spend more time inspecting additional encoding possibilities and decide on the quality gain. Lower value can result in faster processing time at the expense of larger file size and lower compression quality.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Tried to do something similar but this is much simpler. Not big in PS. Didn't realize at the time there was a
ForEach-Object
.Couple notes,
-q
defaults to 75, no need to define it otherwise. Also, I think you could use$_.BaseName
instead of$([io.path]::GetFileNameWithoutExtension($_))
. But to each their own.What I'm using based off of this.
Also to do all sub-folders.