-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathconvert_icon.ps1
More file actions
27 lines (22 loc) · 863 Bytes
/
convert_icon.ps1
File metadata and controls
27 lines (22 loc) · 863 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
Add-Type -AssemblyName System.Drawing
$source = "$PSScriptRoot\extension\logo.png"
$dest = "$PSScriptRoot\assets\icon.ico"
if (Test-Path $source) {
try {
$img = [System.Drawing.Bitmap]::FromFile($source)
# Create a new bitmap with standard icon size if needed, but let's try direct conversion first
# But for best quality, let's just use GetHicon
$iconHandle = $img.GetHicon()
$icon = [System.Drawing.Icon]::FromHandle($iconHandle)
$fs = New-Object System.IO.FileStream($dest, [System.IO.FileMode]::Create)
$icon.Save($fs)
$fs.Close()
$icon.Dispose() # Important to release handle
$img.Dispose()
Write-Host "Success: Created $dest"
} catch {
Write-Host "Error: $_"
}
} else {
Write-Host "Source file not found: $source"
}