move to imagemagick to convert icon

This commit is contained in:
Stepland 2023-07-29 01:09:45 +02:00
parent 6d0d225b82
commit 79de731c0d
3 changed files with 14 additions and 17 deletions

View File

@ -1,15 +0,0 @@
import argparse
from io import BytesIO
from pathlib import Path
import cairosvg
from PIL import Image
parser = argparse.ArgumentParser(description="Render the given .svg file to a windows .ico file")
parser.add_argument("svg", type=Path)
args = parser.parse_args()
png_data = BytesIO(cairosvg.svg2png(url=str(args.svg), parent_height=256, parent_width=256))
image = Image.open(png_data, formats=["PNG"])
image.save(args.svg.with_suffix(".ico"), format="ICO")

14
utils/render_windows_icon.sh Executable file
View File

@ -0,0 +1,14 @@
#!/bin/bash
if (( $# < 1 )); then
echo "usage : $0 SVG_FILE"
exit 1
fi
ICON_PATH="$(echo $1 | sed 's/[.]svg/.ico/')"
convert \
-density 300 \
-define icon:auto-resize=256,128,96,64,48,32,16 \
-background none \
"$1" "$ICON_PATH"

View File

@ -1,2 +0,0 @@
CairoSVG==2.7.0
Pillow==10.0.0