Created
January 27, 2022 13:41
-
-
Save umyuu/1163516b38929a432a8b0dda1f3e1a88 to your computer and use it in GitHub Desktop.
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
@powershell -NoProfile -ExecutionPolicy Unrestricted "$s=[scriptblock]::create((gc \"%~f0\"|?{$_.readcount -gt 1})-join\"`n\");&$s "%~dp1 %*&goto:eof | |
function Convert-Webp { | |
param ($FileName) | |
$Extension = [System.IO.Path]::GetExtension($FileName) | |
if ($Extension -eq ".webp") { | |
return; | |
} | |
$FilePath = [System.IO.Path]::GetDirectoryName($FileName) | |
Write-Output "==================" | |
Write-Output $FileName | |
Write-Output "==================" | |
$GenerateFileName = [System.IO.Path]::ChangeExtension($FileName, ".webp") | |
Write-Output "<source: $FileName>" | |
$WebpPath = $FilePath + "\cwebp.exe"; | |
$Arguments = @("-preset photo", "-metadata icc", "-sharp_yuv", "-o" + $GenerateFileName, "-progress", "-short", "" +$FileName) -join " " | |
Write-Output $WebpPath | |
Write-Output $Arguments | |
Start-Process -FilePath $WebpPath -ArgumentList $Arguments | |
Write-Output "----------------" | |
} | |
Convert-Webp $args[1] | |
Start-Sleep -s 10 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment