correcting/theming icons

This commit is contained in:
Jordan Wages 2025-07-08 01:06:09 -05:00
commit b29d5c702e
85 changed files with 43 additions and 6 deletions

View file

@ -1,6 +1,11 @@
$svgDir = "./svg"
$outDir = "./img"
$sizes = @(16, 32, 64)
$themes = @{
"light" = "#000000"
"dark" = "#ffffff"
}
$tempSvg = "temp.svg"
# Ensure output directory exists
if (!(Test-Path -Path $outDir)) {
@ -13,16 +18,48 @@ if (-not (Get-Command "inkscape" -ErrorAction SilentlyContinue)) {
exit 1
}
# Process SVGs
# Helper: inject color into <svg> tag
function Inject-Color {
param ($original, $color)
$content = Get-Content $original -Raw
if ($content -match '<svg[^>]*>') {
# Inject color style
$patched = $content -replace '<svg([^>]*?)>', "<svg`$1 style=`"color: $color`">"
Set-Content -Path $tempSvg -Value $patched
}
else {
throw "Couldn't find <svg> tag to patch."
}
}
# Process each SVG file
Get-ChildItem -Path $svgDir -Filter *.svg | ForEach-Object {
$svgPath = $_.FullName
$baseName = $_.BaseName
foreach ($size in $sizes) {
$outFile = Join-Path $outDir "$baseName-$size.png"
Write-Host "Converting $($_.Name) to $outFile ($size x $size)..."
& inkscape "$svgPath" --export-type=png --export-filename="$outFile" --export-width=$size --export-height=$size
foreach ($theme in $themes.Keys) {
$color = $themes[$theme]
# Create themed temp SVG
Inject-Color $svgPath $color
foreach ($size in $sizes) {
$outFile = Join-Path $outDir "$baseName-$theme-$size.png"
Write-Host "Exporting $outFile (color $color)..."
& inkscape $tempSvg `
--export-type=png `
--export-filename="$outFile" `
--export-width=$size `
--export-height=$size `
--actions="export-do"
}
}
# Cleanup
if (Test-Path $tempSvg) {
Remove-Item $tempSvg -Force
}
}
Write-Host "Conversion complete."
Write-Host "Done generating light/dark themed PNGs."