-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_icon_icns.sh
More file actions
executable file
·32 lines (24 loc) · 872 Bytes
/
Copy pathbuild_icon_icns.sh
File metadata and controls
executable file
·32 lines (24 loc) · 872 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/env bash
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "$0")" && pwd)"
SOURCE_PNG="${1:-$ROOT_DIR/icon.png}"
OUTPUT_ICNS="${2:-$ROOT_DIR/assets/CompressImage.icns}"
TEMP_DIR="$(mktemp -d "${TMPDIR:-/tmp}/compressimage.icon.XXXXXX")"
ICONSET_DIR="$TEMP_DIR/CompressImage.iconset"
cleanup() {
rm -rf "$TEMP_DIR"
}
trap cleanup EXIT
if [[ ! -f "$SOURCE_PNG" ]]; then
echo "Icon source not found: $SOURCE_PNG" >&2
exit 1
fi
mkdir -p "$(dirname "$OUTPUT_ICNS")"
mkdir -p "$ICONSET_DIR"
for size in 16 32 128 256 512; do
sips -z "$size" "$size" "$SOURCE_PNG" --out "$ICONSET_DIR/icon_${size}x${size}.png" >/dev/null
retina_size=$((size * 2))
sips -z "$retina_size" "$retina_size" "$SOURCE_PNG" --out "$ICONSET_DIR/icon_${size}x${size}@2x.png" >/dev/null
done
iconutil -c icns "$ICONSET_DIR" -o "$OUTPUT_ICNS"
echo "Generated app icon: $OUTPUT_ICNS"