Skip to content

Commit 32b7939

Browse files
committed
added png2icns script and icns version of logo
1 parent 9cb68e0 commit 32b7939

File tree

2 files changed

+85
-0
lines changed

2 files changed

+85
-0
lines changed

logo/logo.icns

303 KB
Binary file not shown.

png2icns.sh

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
#!/bin/sh
2+
#
3+
# Originally developed by dave@bitboss.ca
4+
# https://github.com/bitboss-ca/png2icns
5+
6+
7+
# Exec Paths
8+
SIPS='/usr/bin/sips'
9+
ICONUTIL='/usr/bin/iconutil'
10+
if [ ! -x "${SIPS}" ]; then
11+
echo "Cannot find required SIPS executable at: ${SIPS}" >&2
12+
exit 1;
13+
fi
14+
if [ ! -x "${ICONUTIL}" ]; then
15+
echo "Cannot find required ICONUTIL executable at: ${ICONUTIL}" >&2
16+
exit 1;
17+
fi
18+
19+
# Parameters
20+
SOURCE=$1
21+
22+
# Get source image
23+
if [ -z "${SOURCE}" ]; then
24+
echo "No source image specified, searching in current directory...\c"
25+
SOURCE=$( ls *.png | head -n1 )
26+
if [ -z "${SOURCE}" ]; then
27+
echo "No source image specified and none found."
28+
exit 1;
29+
else
30+
echo "FOUND";
31+
fi
32+
fi
33+
34+
35+
# File Infrastructure
36+
NAME=$(basename "${SOURCE}")
37+
EXT="${NAME##*.}"
38+
BASE="${NAME%.*}"
39+
ICONSET="${BASE}.iconset"
40+
41+
# Debug Info
42+
echo "SOURCE: ${SOURCE}"
43+
echo "NAME: $NAME"
44+
echo "BASE: $BASE"
45+
echo "EXT: $EXT"
46+
echo "ICONSET: $ICONSET"
47+
48+
# Get source image info
49+
SRCWIDTH=$( $SIPS -g pixelWidth "${SOURCE}" | tail -n1 | awk '{print $2}')
50+
SRCHEIGHT=$( $SIPS -g pixelHeight "${SOURCE}" | tail -n1 | awk '{print $2}' )
51+
SRCFORMAT=$( $SIPS -g format "${SOURCE}" | tail -n1 | awk '{print $2}' )
52+
53+
# Debug Info
54+
echo "SRCWIDTH: $SRCWIDTH"
55+
echo "SRCHEIGHT: $SRCHEIGHT"
56+
echo "SRCFORMAT: $SRCFORMAT"
57+
58+
# Check The Source Image
59+
if [ "x${SRCWIDTH}" != "x1024" ] || [ "x${SRCHEIGHT}" != "x1024" ]; then
60+
echo "ERR: Source image should be 1024 x 1024 pixels." >&2
61+
exit 1;
62+
fi
63+
if [ "x${SRCFORMAT}" != "xpng" ]; then
64+
echo "ERR: Source image format should be png." >&2
65+
exit 1;
66+
fi
67+
68+
# Resample image into iconset
69+
mkdir "${ICONSET}"
70+
$SIPS -s format png --resampleWidth 1024 "${SOURCE}" --out "${ICONSET}/icon_512x512@2x.png" > /dev/null 2>&1
71+
$SIPS -s format png --resampleWidth 512 "${SOURCE}" --out "${ICONSET}/icon_512x512.png" > /dev/null 2>&1
72+
cp "${ICONSET}/icon_512x512.png" "${ICONSET}/icon_256x256@2x.png"
73+
$SIPS -s format png --resampleWidth 256 "${SOURCE}" --out "${ICONSET}/icon_256x256.png" > /dev/null 2>&1
74+
cp "${ICONSET}/icon_256x256.png" "${ICONSET}/icon_128x128@2x.png"
75+
$SIPS -s format png --resampleWidth 128 "${SOURCE}" --out "${ICONSET}/icon_128x128.png" > /dev/null 2>&1
76+
$SIPS -s format png --resampleWidth 64 "${SOURCE}" --out "${ICONSET}/icon_32x32@2x.png" > /dev/null 2>&1
77+
$SIPS -s format png --resampleWidth 32 "${SOURCE}" --out "${ICONSET}/icon_32x32.png" > /dev/null 2>&1
78+
cp "${ICONSET}/icon_32x32.png" "${ICONSET}/icon_16x16@2x.png"
79+
$SIPS -s format png --resampleWidth 16 "${SOURCE}" --out "${ICONSET}/icon_16x16.png" > /dev/null 2>&1
80+
81+
# Create an icns file from the iconset
82+
$ICONUTIL -c icns "${ICONSET}"
83+
84+
# Clean up the iconset
85+
rm -rf "${ICONSET}"

0 commit comments

Comments
 (0)