Skip to content

Instantly share code, notes, and snippets.

@umyuu
Created January 27, 2022 13:41
Show Gist options
  • Save umyuu/1163516b38929a432a8b0dda1f3e1a88 to your computer and use it in GitHub Desktop.
Save umyuu/1163516b38929a432a8b0dda1f3e1a88 to your computer and use it in GitHub Desktop.
@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