1 parent
24b624301c
commit
6213fec7d2
29 files changed
+4058
-5
No files matched your search
@@ -0,0 +1,28 @@
|
||||
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()
|
||||
}
|
||||
Reference in new issue
Block a user