Skip to content

Instantly share code, notes, and snippets.

@pinscript
Created September 18, 2017 05:25
Show Gist options
  • Save pinscript/bdb7228743beacf1d25d88725f0d1909 to your computer and use it in GitHub Desktop.
Save pinscript/bdb7228743beacf1d25d88725f0d1909 to your computer and use it in GitHub Desktop.
Function Compress-Images() {
if(!(Test-Path -Path "Compressed")) {
New-Item -ItemType Directory -Force -Path "Compressed"
}
if((Get-Command "guetzli_windows_x86-64.exe" -ErrorAction SilentlyContinue) -eq $null) {
Write-Host "Could not find guetzli_windows_x86-64.exe in path."
}
$files = Get-ChildItem -Filter *.jpg
foreach($file in $files) {
$name = $file.Name
Write-Host "Compressing $($name)"
guetzli_windows_x86-64.exe --quality 84 "$($name)" "Compressed/$($name)"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment