29 lines
1.1 KiB
PowerShell
29 lines
1.1 KiB
PowerShell
param(
|
|
[Parameter(Mandatory = $true)][string]$IconPath,
|
|
[Parameter(Mandatory = $true)][string]$OutputFolder
|
|
)
|
|
$ErrorActionPreference = 'Stop'
|
|
Add-Type -AssemblyName System.Drawing
|
|
$icon = New-Object System.Drawing.Icon((Resolve-Path -LiteralPath $IconPath).Path, 256, 256)
|
|
$bitmap = $icon.ToBitmap()
|
|
try {
|
|
foreach ($size in @(44, 150)) {
|
|
$destination = Join-Path $OutputFolder "Logo$size.png"
|
|
if (Test-Path -LiteralPath $destination) { throw "Asset already exists: $destination" }
|
|
$scaled = New-Object System.Drawing.Bitmap($size, $size)
|
|
$graphics = [System.Drawing.Graphics]::FromImage($scaled)
|
|
try {
|
|
$graphics.Clear([System.Drawing.Color]::Transparent)
|
|
$graphics.InterpolationMode = [System.Drawing.Drawing2D.InterpolationMode]::HighQualityBicubic
|
|
$graphics.DrawImage($bitmap, 0, 0, $size, $size)
|
|
$scaled.Save($destination, [System.Drawing.Imaging.ImageFormat]::Png)
|
|
} finally {
|
|
$graphics.Dispose()
|
|
$scaled.Dispose()
|
|
}
|
|
}
|
|
} finally {
|
|
$bitmap.Dispose()
|
|
$icon.Dispose()
|
|
}
|