param( [validatescript({ Test-Path $_ -PathType Any })] [system.io.fileinfo]$in, $out = (Split-Path -Parent $in), $scale = 128 ) if (!(Get-Command "magick.exe" -ErrorAction SilentlyContinue)) { Write-Host "There's no magick.exe to work with!" exit } if (Test-Path $in -PathType container) { $out_dir = "$out\x$scale\" if (!(Test-Path $out_dir)) { New-Item "$out_dir" -ItemType directory } foreach ($image in Get-ChildItem "$in*" -Include *.png) { $scaled = "$out_dir$($image.BaseName)$($image.Extension)" Write-Host $scaled magick $image.FullName -scale "$($scale * 100)%" $scaled } } else { $scaled = "$out\$($in.BaseName)-x$scale$($in.Extension)" Write-Host $scaled magick $in.FullName -scale "$($scale * 100)%" $scaled }