-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconvert-icon.ps1
More file actions
42 lines (34 loc) · 1.17 KB
/
Copy pathconvert-icon.ps1
File metadata and controls
42 lines (34 loc) · 1.17 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# PowerShell script to convert PNG to ICO
Add-Type -AssemblyName System.Drawing
# Load the PNG image
$pngPath = "build\icon.png"
$icoPath = "build\icon.ico"
if (Test-Path $pngPath) {
try {
# Load the image
$bitmap = [System.Drawing.Bitmap]::new($pngPath)
# Create different sized versions
$sizes = @(16, 32, 48, 64, 128, 256)
$icons = @()
foreach ($size in $sizes) {
$resized = [System.Drawing.Bitmap]::new($bitmap, $size, $size)
$icons += $resized
}
# Save as ICO (this is a simplified approach)
$bitmap.Save($icoPath, [System.Drawing.Imaging.ImageFormat]::Icon)
Write-Host "Successfully converted PNG to ICO"
# Cleanup
$bitmap.Dispose()
foreach ($icon in $icons) {
$icon.Dispose()
}
}
catch {
Write-Error "Failed to convert: $($_.Exception.Message)"
# Fallback: just copy PNG as ICO (not ideal but might work)
Copy-Item $pngPath $icoPath
Write-Host "Copied PNG as ICO (fallback method)"
}
} else {
Write-Error "PNG file not found: $pngPath"
}