Files
NexaVPN/scripts/generate_ico_from_png.py
nessi 61d2b4b25c feat: add branding assets and favicon support across admin-web and desktop-client
Add NexaVPN logo images (full logo and mark-only variants) to admin-web and desktop-client public directories. Add favicon.ico and favicon.png to admin-web, and icon.png to desktop-client. Update index.html files to reference favicon assets. Add icon.png and icon.ico to desktop-client Tauri icons directory and configure bundle.icon in tauri.conf.json. Update Layout component to display logo in sidebar brand-block with
2026-03-17 19:37:58 +01:00

51 lines
1.1 KiB
Python

#!/usr/bin/env python3
from __future__ import annotations
import struct
import sys
from pathlib import Path
PNG_SIGNATURE = b"\x89PNG\r\n\x1a\n"
def main() -> int:
if len(sys.argv) != 3:
print("usage: generate_ico_from_png.py <input.png> <output.ico>", file=sys.stderr)
return 1
source = Path(sys.argv[1])
target = Path(sys.argv[2])
png = source.read_bytes()
if not png.startswith(PNG_SIGNATURE):
print(f"{source} is not a PNG file", file=sys.stderr)
return 1
width = int.from_bytes(png[16:20], "big")
height = int.from_bytes(png[20:24], "big")
width_byte = 0 if width >= 256 else width
height_byte = 0 if height >= 256 else height
header = struct.pack("<HHH", 0, 1, 1)
directory = struct.pack(
"<BBBBHHII",
width_byte,
height_byte,
0,
0,
1,
32,
len(png),
len(header) + 16,
)
target.parent.mkdir(parents=True, exist_ok=True)
target.write_bytes(header + directory + png)
print(f"wrote {target}")
return 0
if __name__ == "__main__":
raise SystemExit(main())