-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuildAppIcon.ps1
More file actions
53 lines (44 loc) · 1.33 KB
/
Copy pathbuildAppIcon.ps1
File metadata and controls
53 lines (44 loc) · 1.33 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
43
44
45
46
47
48
49
50
51
52
53
#Requires -Version 5.1
<#
.SYNOPSIS
Builds assets\dataEntryAutonoma.ico from assets\dataEntryAutonoma.svg.
#>
$ErrorActionPreference = "Stop"
$PROJECT_ROOT = $PSScriptRoot
$ASSETS_DIR = Join-Path $PROJECT_ROOT "assets"
$SVG_FILE = Join-Path $ASSETS_DIR "dataEntryAutonoma.svg"
$ICO_FILE = Join-Path $ASSETS_DIR "dataEntryAutonoma.ico"
$PNG_FILE = Join-Path $ASSETS_DIR "dataEntryAutonoma-256.png"
if (-not (Test-Path $SVG_FILE)) {
Write-Error "SVG source not found: $SVG_FILE"
}
New-Item -ItemType Directory -Force -Path $ASSETS_DIR | Out-Null
Write-Host "Rendering icon PNG from SVG..."
Push-Location $ASSETS_DIR
try {
npx --yes @resvg/resvg-js-cli --fit-width 256 --fit-height 256 dataEntryAutonoma.svg dataEntryAutonoma-256.png | Out-Null
}
finally {
Pop-Location
}
if (-not (Test-Path $PNG_FILE)) {
Write-Error "PNG render failed: $PNG_FILE"
}
Write-Host "Building ICO..."
Add-Type -AssemblyName System.Drawing
$bitmap = [System.Drawing.Bitmap]::FromFile($PNG_FILE)
try {
$icon = [System.Drawing.Icon]::FromHandle($bitmap.GetHicon())
$stream = [System.IO.File]::Create($ICO_FILE)
try {
$icon.Save($stream)
}
finally {
$stream.Close()
}
}
finally {
$bitmap.Dispose()
}
$sizeKb = [math]::Round((Get-Item $ICO_FILE).Length / 1KB, 1)
Write-Host ('Done. {0} ({1} KB)' -f $ICO_FILE, $sizeKb)