2023-02-24 20:39:49 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
# requires imagemagick and png2icns (usually found in libicns)
|
|
|
|
|
2023-02-24 20:47:56 +00:00
|
|
|
convert logo.svg logo.png
|
|
|
|
|
2023-02-24 20:39:49 +00:00
|
|
|
convert \
|
|
|
|
-density 300 \
|
|
|
|
-define icon:auto-resize=256,128,96,64,48,32,16 \
|
|
|
|
-background none \
|
|
|
|
logo.svg logo.ico
|
|
|
|
|
|
|
|
|
|
|
|
# see: https://gist.github.com/plroebuck/af19a26c908838c7f9e363c571199deb
|
|
|
|
|
|
|
|
icnsfilename="logo"
|
|
|
|
iconsetdirname=$(mktemp -d -t logo-XXXXXXXXXX)
|
|
|
|
sizes=( 16 32 128 256 512 )
|
|
|
|
#densities=( 72 144 )
|
|
|
|
densities=( 72 )
|
|
|
|
|
|
|
|
for size in "${sizes[@]}"
|
|
|
|
do
|
|
|
|
dimen="${size}x${size}"
|
|
|
|
for density in "${densities[@]}"
|
|
|
|
do
|
|
|
|
if [ "${density}" == "72" ];
|
|
|
|
then
|
|
|
|
## std
|
|
|
|
resolution="${dimen}"
|
|
|
|
scale=""
|
|
|
|
else
|
|
|
|
## hires
|
|
|
|
resolution="$(( $size * 2 ))x$(( $size * 2 ))"
|
|
|
|
scale="@2x"
|
|
|
|
fi
|
|
|
|
pngfilename="${iconsetdirname}/icon_${dimen}${scale}.png"
|
|
|
|
#echo \
|
|
|
|
convert \
|
|
|
|
-background "none" \
|
|
|
|
-density "${density}" \
|
|
|
|
-resize "${resolution}!" \
|
|
|
|
-units "PixelsPerInch" \
|
|
|
|
logo.svg "${pngfilename}"
|
|
|
|
if [ "$?" -ne 0 ]; then
|
|
|
|
echo "error creating icon file: ${pngfilename}" >&2
|
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
echo "wrote temp icon file: ${pngfilename}" >&2
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
|
|
png2icns logo.icns "${iconsetdirname}"/icon_*.png
|