Adding logos
BIN
resources/img/logo-dark-16.png
Normal file
|
After Width: | Height: | Size: 619 B |
BIN
resources/img/logo-dark-32.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
resources/img/logo-dark-64.png
Normal file
|
After Width: | Height: | Size: 2.2 KiB |
BIN
resources/img/logo-light-16.png
Normal file
|
After Width: | Height: | Size: 619 B |
BIN
resources/img/logo-light-32.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
resources/img/logo-light-64.png
Normal file
|
After Width: | Height: | Size: 2.2 KiB |
BIN
resources/img/logo.png
Normal file
|
After Width: | Height: | Size: 18 KiB |
BIN
resources/img/logo128.png
Normal file
|
After Width: | Height: | Size: 4.5 KiB |
BIN
resources/img/logo16.png
Normal file
|
After Width: | Height: | Size: 619 B |
BIN
resources/img/logo32.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
resources/img/logo48.png
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
resources/img/logo64.png
Normal file
|
After Width: | Height: | Size: 2.2 KiB |
BIN
resources/img/logo96.png
Normal file
|
After Width: | Height: | Size: 3.3 KiB |
1
resources/svg/.gitkeep
Normal file
|
|
@ -0,0 +1 @@
|
|||
|
||||
|
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 2.3 KiB |
149
resources/svg2img.ps1
Normal file
|
|
@ -0,0 +1,149 @@
|
|||
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||
$svgDir = Join-Path $scriptDir "svg"
|
||||
$outDir = Join-Path $scriptDir "img"
|
||||
$logoSvg = Join-Path $scriptDir "logo.svg"
|
||||
$sizes = @(16, 32, 64)
|
||||
$logoSizes = @(16, 32, 48, 64, 96, 128)
|
||||
$themes = @{
|
||||
"light" = "#000000"
|
||||
"dark" = "#ffffff"
|
||||
}
|
||||
$inkscapeCmd = @()
|
||||
$tmpRoot = if (Test-Path -Path "/tmp") { "/tmp" } else { [System.IO.Path]::GetTempPath() }
|
||||
$tempDir = Join-Path $tmpRoot ("psitransfer-filelink-svg2img-" + [guid]::NewGuid().ToString())
|
||||
$tempSvg = Join-Path $tempDir "themed-icon.svg"
|
||||
|
||||
if (!(Test-Path -Path $outDir)) {
|
||||
New-Item -ItemType Directory -Path $outDir | Out-Null
|
||||
}
|
||||
|
||||
if (!(Test-Path -Path $svgDir)) {
|
||||
New-Item -ItemType Directory -Path $svgDir | Out-Null
|
||||
}
|
||||
|
||||
if (!(Test-Path -Path $tempDir)) {
|
||||
New-Item -ItemType Directory -Path $tempDir | Out-Null
|
||||
}
|
||||
|
||||
function Remove-TempFiles {
|
||||
if (Test-Path -Path $tempDir) {
|
||||
Remove-Item -Path $tempDir -Recurse -Force
|
||||
}
|
||||
}
|
||||
|
||||
function Resolve-InkscapeCommand {
|
||||
$nativeInkscape = Get-Command "inkscape" -ErrorAction SilentlyContinue
|
||||
if ($nativeInkscape) {
|
||||
return @($nativeInkscape.Source)
|
||||
}
|
||||
|
||||
$flatpak = Get-Command "flatpak" -ErrorAction SilentlyContinue
|
||||
if ($flatpak) {
|
||||
& $flatpak.Source info org.inkscape.Inkscape *> $null
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
return @(
|
||||
$flatpak.Source,
|
||||
"run",
|
||||
"--filesystem=$scriptDir",
|
||||
"--filesystem=/tmp",
|
||||
"--command=inkscape",
|
||||
"org.inkscape.Inkscape"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
throw "Inkscape CLI is not installed or not in PATH, and Flatpak Inkscape (org.inkscape.Inkscape) was not found."
|
||||
}
|
||||
|
||||
function Export-Png {
|
||||
param (
|
||||
[string] $InputSvg,
|
||||
[string] $OutFile,
|
||||
[int] $Size
|
||||
)
|
||||
|
||||
Write-Host "Exporting $OutFile..."
|
||||
Invoke-Inkscape @(
|
||||
$InputSvg,
|
||||
"--export-type=png",
|
||||
"--export-filename=$OutFile",
|
||||
"--export-width=$Size",
|
||||
"--export-height=$Size",
|
||||
"--actions=export-do"
|
||||
)
|
||||
}
|
||||
|
||||
function Invoke-Inkscape {
|
||||
param (
|
||||
[string[]] $Arguments
|
||||
)
|
||||
|
||||
& $inkscapeCmd[0] @($inkscapeCmd | Select-Object -Skip 1) @Arguments
|
||||
}
|
||||
|
||||
function Inject-Color {
|
||||
param (
|
||||
[string] $Original,
|
||||
[string] $Color
|
||||
)
|
||||
|
||||
$content = Get-Content $Original -Raw
|
||||
|
||||
if ($content -match '<svg[^>]*>') {
|
||||
$patched = $content -replace '<svg([^>]*?)>', "<svg`$1 style=`"color: $Color`">"
|
||||
Set-Content -Path $tempSvg -Value $patched
|
||||
}
|
||||
else {
|
||||
throw "Couldn't find <svg> tag to patch."
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
$inkscapeCmd = Resolve-InkscapeCommand
|
||||
|
||||
if (Test-Path -Path $logoSvg) {
|
||||
foreach ($size in $logoSizes) {
|
||||
Export-Png -InputSvg $logoSvg -OutFile (Join-Path $outDir "logo$size.png") -Size $size
|
||||
}
|
||||
|
||||
Export-Png -InputSvg $logoSvg -OutFile (Join-Path $outDir "logo.png") -Size 512
|
||||
}
|
||||
else {
|
||||
Write-Warning "Logo source not found: $logoSvg"
|
||||
}
|
||||
|
||||
$svgFiles = Get-ChildItem -Path $svgDir -Filter *.svg -ErrorAction SilentlyContinue
|
||||
|
||||
if (-not $svgFiles) {
|
||||
Write-Host "No themed SVG icons found in $svgDir. Logo exports completed."
|
||||
exit 0
|
||||
}
|
||||
|
||||
foreach ($svgFile in $svgFiles) {
|
||||
$svgPath = $svgFile.FullName
|
||||
$baseName = $svgFile.BaseName
|
||||
|
||||
foreach ($theme in $themes.Keys) {
|
||||
$color = $themes[$theme]
|
||||
Inject-Color -Original $svgPath -Color $color
|
||||
|
||||
foreach ($size in $sizes) {
|
||||
$outFile = Join-Path $outDir "$baseName-$theme-$size.png"
|
||||
Write-Host "Exporting $outFile (color $color)..."
|
||||
Invoke-Inkscape @(
|
||||
$tempSvg,
|
||||
"--export-type=png",
|
||||
"--export-filename=$outFile",
|
||||
"--export-width=$size",
|
||||
"--export-height=$size",
|
||||
"--actions=export-do"
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Write-Host "Done generating logo PNGs and light/dark themed icon PNGs."
|
||||
}
|
||||
finally {
|
||||
Remove-TempFiles
|
||||
}
|
||||
144
resources/svg2img.sh
Executable file
|
|
@ -0,0 +1,144 @@
|
|||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
svg_dir="$script_dir/svg"
|
||||
out_dir="$script_dir/img"
|
||||
logo_svg="$script_dir/logo.svg"
|
||||
sizes=(16 32 64)
|
||||
logo_sizes=(16 32 48 64 96 128)
|
||||
themes=(light dark)
|
||||
inkscape_cmd=()
|
||||
temp_dir=""
|
||||
|
||||
cleanup() {
|
||||
if [[ -n "$temp_dir" && -d "$temp_dir" ]]; then
|
||||
rm -rf "$temp_dir"
|
||||
fi
|
||||
}
|
||||
|
||||
trap cleanup EXIT
|
||||
|
||||
get_theme_color() {
|
||||
case "$1" in
|
||||
light) printf '%s\n' '#000000' ;;
|
||||
dark) printf '%s\n' '#ffffff' ;;
|
||||
*)
|
||||
printf 'Unknown theme: %s\n' "$1" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
ensure_temp_svg() {
|
||||
local input_svg="$1"
|
||||
local color="$2"
|
||||
local temp_svg="$3"
|
||||
|
||||
python3 - "$input_svg" "$color" "$temp_svg" <<'PY'
|
||||
import pathlib
|
||||
import re
|
||||
import sys
|
||||
|
||||
input_path = pathlib.Path(sys.argv[1])
|
||||
color = sys.argv[2]
|
||||
output_path = pathlib.Path(sys.argv[3])
|
||||
content = input_path.read_text(encoding="utf-8")
|
||||
patched, count = re.subn(r"<svg([^>]*?)>", f'<svg\\1 style="color: {color}">', content, count=1)
|
||||
if count != 1:
|
||||
raise SystemExit("Couldn't find <svg> tag to patch.")
|
||||
output_path.write_text(patched, encoding="utf-8")
|
||||
PY
|
||||
}
|
||||
|
||||
export_png() {
|
||||
local input_svg="$1"
|
||||
local out_file="$2"
|
||||
local size="$3"
|
||||
|
||||
echo "Exporting $out_file..."
|
||||
"${inkscape_cmd[@]}" "$input_svg" \
|
||||
--export-type=png \
|
||||
--export-filename="$out_file" \
|
||||
--export-width="$size" \
|
||||
--export-height="$size" \
|
||||
--actions=export-do
|
||||
}
|
||||
|
||||
resolve_inkscape_cmd() {
|
||||
if command -v inkscape >/dev/null 2>&1; then
|
||||
inkscape_cmd=(inkscape)
|
||||
return 0
|
||||
fi
|
||||
|
||||
if command -v flatpak >/dev/null 2>&1; then
|
||||
if flatpak info org.inkscape.Inkscape >/dev/null 2>&1; then
|
||||
inkscape_cmd=(
|
||||
flatpak
|
||||
run
|
||||
--filesystem="$script_dir"
|
||||
--filesystem=/tmp
|
||||
--command=inkscape
|
||||
org.inkscape.Inkscape
|
||||
)
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "Inkscape CLI is not installed or not in PATH, and Flatpak Inkscape (org.inkscape.Inkscape) was not found." >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
mkdir -p "$out_dir" "$svg_dir"
|
||||
|
||||
if ! command -v python3 >/dev/null 2>&1; then
|
||||
echo "python3 is required to patch the SVG color attribute." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
resolve_inkscape_cmd
|
||||
temp_dir="$(mktemp -d "/tmp/psitransfer-filelink-svg2img.XXXXXX")"
|
||||
|
||||
if [[ -f "$logo_svg" ]]; then
|
||||
for size in "${logo_sizes[@]}"; do
|
||||
export_png "$logo_svg" "$out_dir/logo${size}.png" "$size"
|
||||
done
|
||||
|
||||
# Keep a generic logo export for docs/UI usage.
|
||||
export_png "$logo_svg" "$out_dir/logo.png" 512
|
||||
else
|
||||
echo "Logo source not found: $logo_svg" >&2
|
||||
fi
|
||||
|
||||
shopt -s nullglob
|
||||
svg_files=("$svg_dir"/*.svg)
|
||||
shopt -u nullglob
|
||||
|
||||
if [[ ${#svg_files[@]} -eq 0 ]]; then
|
||||
echo "No themed SVG icons found in $svg_dir. Logo exports completed."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
temp_svg="$temp_dir/themed-icon.svg"
|
||||
|
||||
for svg_path in "${svg_files[@]}"; do
|
||||
base_name="$(basename "${svg_path%.svg}")"
|
||||
|
||||
for theme in "${themes[@]}"; do
|
||||
color="$(get_theme_color "$theme")"
|
||||
ensure_temp_svg "$svg_path" "$color" "$temp_svg"
|
||||
|
||||
for size in "${sizes[@]}"; do
|
||||
out_file="$out_dir/$base_name-$theme-$size.png"
|
||||
echo "Exporting $out_file (color $color)..."
|
||||
"${inkscape_cmd[@]}" "$temp_svg" \
|
||||
--export-type=png \
|
||||
--export-filename="$out_file" \
|
||||
--export-width="$size" \
|
||||
--export-height="$size" \
|
||||
--actions=export-do
|
||||
done
|
||||
done
|
||||
done
|
||||
|
||||
echo "Done generating logo PNGs and light/dark themed icon PNGs."
|
||||