Batch Resize Using PowerShell
Automates image resize and color correction using Graphics Mill and PowerShell
Download TrialCode snippet
param([String]$inputDir, [String]$outputDir) If (!$inputDir) { echo "inputDir is not specified." Exit } If (!$outputDir) { echo "outputDir is not specified." Exit } [Reflection.Assembly]::LoadFile("C:\Program Files (x86)\Aurigma\Graphics Mill 7 SDK\.Net 3.5\Binaries_x64\Aurigma.GraphicsMill.dll") Get-ChildItem $inputDir -Filter *.jpg | ` Foreach-Object{ write-host $_.FullName Try { $bitmap = new-object Aurigma.GraphicsMill.Bitmap $_.FullName $bitmap.Transforms.Resize(640, 640, [Aurigma.GraphicsMill.Transforms.ResizeInterpolationMode]::High, [Aurigma.GraphicsMill.Transforms.ResizeMode]::Fit) $bitmap.ColorAdjustment.AutoLevels() $bitmap.Save($outputDir + "\" + $_.Name) write-host "Success" -foreground "green" } Catch { write-host "Error" -foreground "red" } Finally { If ($bitmap) { $bitmap.Dispose() } } }
Using
PS C:\> .\resize.ps1 <inputDir> <ouputDir>