Add AppX icons

This commit is contained in:
Christopher Willis-Ford 2018-12-13 17:36:49 -08:00
parent 6537e1f931
commit 7b55741ead
11 changed files with 63 additions and 51 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 194 KiB

After

Width:  |  Height:  |  Size: 194 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB

62
buildResources/make-icons.sh Executable file
View file

@ -0,0 +1,62 @@
#!/bin/bash
SRC=../src/icon/ScratchDesktop.svg
OUT_ICONSET=ScratchDesktop.iconset
OUT_ICNS=ScratchDesktop.icns
OUT_ICO=ScratchDesktop.ico
TMP_ICO=tmp
ICO_BASIC_SIZES="16 24 32 48 256"
ICO_EXTRA_SIZES="20 30 36 40 60 64 72 80 96 512"
if command -v pngcrush >/dev/null 2>&1; then
function optimize () {
pngcrush -new -brute -ow "$@"
}
else
echo "pngcrush is not available - skipping PNG optimization"
function optimize () {
echo "Not optimizing:" "$@"
}
fi
# usage: resize newWidth newHeight input output [otherOptions...]
function resize () {
WIDTH=$1
HEIGHT=$2
SRC=$3
DST=$4
shift 4
convert -background none -resize "${WIDTH}x${HEIGHT}" -extent "${WIDTH}x${HEIGHT}" -gravity center "$@" "${SRC}" "${DST}"
optimize "${DST}"
}
if command -v convert >/dev/null 2>&1; then
# Mac
if command -v iconutil >/dev/null 2>&1; then
mkdir -p "${OUT_ICONSET}"
for SIZE in 16 32 128 256 512; do
SIZE2=`expr "${SIZE}" '*' 2`
resize "${SIZE}" "${SIZE}" "${SRC}" "${OUT_ICONSET}/icon_${SIZE}x${SIZE}.png" -density 72 -units PixelsPerInch
resize "${SIZE2}" "${SIZE2}" "${SRC}" "${OUT_ICONSET}/icon_${SIZE}x${SIZE}@2x.png" -density 144 -units PixelsPerInch
done
iconutil -c icns --output "${OUT_ICNS}" "${OUT_ICONSET}"
else
echo "iconutil is not available - skipping ICNS and ICONSET"
fi
# Windows ICO
mkdir -p "${TMP_ICO}"
for SIZE in ${ICO_BASIC_SIZES} ${ICO_EXTRA_SIZES}; do
resize "${SIZE}" "${SIZE}" "${SRC}" "${TMP_ICO}/icon_${SIZE}x${SIZE}.png"
done
# Asking for "Zip" compression actually results in PNG compression
convert "${TMP_ICO}"/icon_*.png -colorspace sRGB -compress Zip "${OUT_ICO}"
# Windows AppX
resize 44 44 "${SRC}" 'Square44x44Logo.png'
resize 150 150 "${SRC}" 'Square150x150Logo.png'
resize 400 400 "${SRC}" 'StoreLogo.png'
resize 300 150 "${SRC}" 'Wide300x150Logo.png'
else
echo "ImageMagick is not available - cannot convert icons"
fi

View file

@ -1,4 +1,5 @@
directories:
buildResources: buildResources
output: dist
appId: edu.mit.scratch.scratch-desktop
productName: "Scratch Desktop"

View file

@ -1,51 +0,0 @@
#!/bin/sh
SRC=../src/icon/ScratchDesktop.svg
OUT_ICONSET=ScratchDesktop.iconset
OUT_ICNS=ScratchDesktop.icns
OUT_ICO=ScratchDesktop.ico
TMP_ICO=tmp
ICO_BASIC_SIZES="16 24 32 48 256"
ICO_EXTRA_SIZES="20 30 36 40 60 64 72 80 96 512"
if command -v convert >/dev/null 2>&1; then
# Mac
if command -v iconutil >/dev/null 2>&1; then
mkdir -p "${OUT_ICONSET}"
for SIZE in 16 32 128 256 512; do
SIZE2=`expr "${SIZE}" '*' 2`
convert -background none -density 72 -units PixelsPerInch -resize "!${SIZE}x${SIZE}" "${SRC}" "${OUT_ICONSET}/icon_${SIZE}x${SIZE}.png"
convert -background none -density 144 -units PixelsPerInch -resize "!${SIZE2}x${SIZE2}" "${SRC}" "${OUT_ICONSET}/icon_${SIZE}x${SIZE}@2x.png"
# sips doesn't support SVG
#sips -s dpiWidth 72 -s dpiHeight 72 -z "${SIZE}" "${SIZE}" "${SRC}" --out "${OUT_ICONSET}/icon_${SIZE}x${SIZE}.png"
#sips -s dpiWidth 144 -s dpiHeight 144 -z "${SIZE2}" "${SIZE2}" "${SRC}" --out "${OUT_ICONSET}/icon_${SIZE}x${SIZE}@2x.png"
done
if command -v pngcrush >/dev/null 2>&1; then
for PNG in "${OUT_ICONSET}"/icon_*.png; do
pngcrush -new -brute -ow "${PNG}"
done
else
echo "pngcrush is not available - skipping PNG optimization"
fi
iconutil -c icns --output "${OUT_ICNS}" "${OUT_ICONSET}"
else
echo "iconutil is not available - skipping ICNS and ICONSET"
fi
# Windows
mkdir -p "${TMP_ICO}"
for SIZE in ${ICO_BASIC_SIZES} ${ICO_EXTRA_SIZES}; do
convert -background none -resize "!${SIZE}x${SIZE}" "${SRC}" "${TMP_ICO}/icon_${SIZE}x${SIZE}.png"
done
if command -v pngcrush >/dev/null 2>&1; then
for PNG in "${TMP_ICO}"/icon_*.png; do
pngcrush -new -brute -ow "${PNG}"
done
else
echo "pngcrush is not available - skipping PNG optimization"
fi
# Asking for "Zip" compression actually results in PNG compression
convert "${TMP_ICO}"/icon_*.png -colorspace sRGB -compress Zip "${OUT_ICO}"
else
echo "ImageMagick is not available - cannot convert icons"
fi