milsko/tools/icon-converter.sh

15 lines
463 B
Bash
Raw Normal View History

2026-05-10 03:22:24 +09:00
#!/bin/sh
if [ "x$1" = "x" -o "x$2" = "x" ]; then
echo "Usage: $0 input name"
exit 1
fi
GEO=`convert $1 json:- 2>/dev/null | jq -r '(.[0].image.geometry.width | tostring) + "x" + (.[0].image.geometry.height | tostring)'`
WIDTH=`echo $GEO | cut -dx -f1`
HEIGHT=`echo $GEO | cut -dx -f2`
echo "MwU32 $2[] = {"
echo " ($WIDTH << 16) | $HEIGHT,"
convert $1 txt:- 2>/dev/null | grep -oE '#[0-9a-fA-F]{8}' | sed 's/^#/ 0x/' | sed -E 's/$/,/'
echo " 0"
echo "};"