actual/packages/desktop-electron/icons/generate-icns

42 lines
1.3 KiB
Text
Raw Normal View History

2022-04-29 02:44:38 +00:00
#!/bin/sh -e -x
echo "Generating..."
if [ $# -ne 1 ]; then
echo "Usage: generate filename.svg"
exit 100
fi
filename="$1"
name=${filename%.*}
ext=${filename##*.}
echo "processing: $name"
dest="$name".iconset
mkdir "$dest"
# macOS icon
convert -background none -gravity center -extent '1190x1190' "$1" tmp.png
src=tmp.png
convert -background none -resize '!16x16' "$src" "$dest/icon_16x16.png"
convert -background none -resize '!32x32' "$src" "$dest/icon_16x16@2x.png"
cp "$dest/icon_16x16@2x.png" "$dest/icon_32x32.png"
convert -background none -resize '!64x64' "$src" "$dest/icon_32x32@2x.png"
convert -background none -resize '!128x128' "$src" "$dest/icon_128x128.png"
convert -background none -resize '!256x256' "$src" "$dest/icon_128x128@2x.png"
cp "$dest/icon_128x128@2x.png" "$dest/icon_256x256.png"
convert -background none -resize '!512x512' "$src" "$dest/icon_256x256@2x.png"
cp "$dest/icon_256x256@2x.png" "$dest/icon_512x512.png"
convert -background none -resize '!1024x1024' "$src" "$dest/icon_512x512@2x.png"
iconutil -c icns "$dest"
rm -R "$dest"
# Windows icon
convert "$src" \
\( -clone 0 -resize 16x16 \) \
\( -clone 0 -resize 32x32 \) \
\( -clone 0 -resize 48x48 \) \
\( -clone 0 -resize 64x64 \) \
\( -clone 0 -resize 256x256 \) \
-delete 0 icon.ico
rm tmp.png