Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # JPEG Optimizer
- # Optimizes JPEGs in a folder using Google JPEG optimizer "Guetzli"
- # Version: 1.0A
- $optimizerTool = 'C:\Users\Dean\Documents\Batch Scripts\Commands\guetzli-x64.exe'
- $inputFolder = 'C:\webserver\htdocs\webman1\resources\jpg\avatars'
- $outputFolder = 'C:\webserver\htdocs\webman1\resources\jpg\avatars\converted'
- # End Edits
- if((Test-Path $optimizerTool) -ne $true)
- {
- Write-Host 'Please check optimizerTool path is correct: '$optimizerTool -ForegroundColor Red
- exit
- }
- if((Test-Path $inputFolder) -ne $true)
- {
- Write-Host 'Please check inputFolder path is correct: '$inputFolder -ForegroundColor Red
- exit
- }
- if((Test-Path $outputFolder) -ne $true)
- {
- Write-Host 'Please check outputFolder path is correct: '$outputFolder -ForegroundColor Red
- exit
- }
- $jpegList = Get-ChildItem -Path $inputFolder -Filter '*.jpg'
- $numberOfJPEGs = $jpegList | Measure-Object | ForEach-Object{$_.Count}
- Write-Host 'Found'$numberOfJPEGs' images to optimize. Continue?' -ForegroundColor Cyan
- pause
- Write-Host 'Optimizing JPEG images using guetzli, please wait..' -ForegroundColor Yellow
- foreach($file in $jpegList)
- {
- #Write-Host 'Optimizing "'$file.Name.'", please wait..' -ForegroundColor Cyan
- Write-Host "Optimizing $file, please wait.." -ForegroundColor Cyan
- $output = '"'+$file.FullName+'" "'+$outputFolder+'\'+$file.Name+'"'
- $arguments = '--quality 99 '+$output
- # $arguments
- $process = Start-Process $optimizerTool -ArgumentList $arguments -PassThru -Wait -NoNewWindow
- $process.WaitForExit()
- }
- Write-Host 'Optimized JPEG images using guetzli. Please check the output files in: '$outputFolder -ForegroundColor Green
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement