-
Notifications
You must be signed in to change notification settings - Fork 0
/
favicon
executable file
·44 lines (36 loc) · 1.04 KB
/
favicon
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
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/bash
INPUT_IMAGE="$1"
OUTPUT_DIR="$2"
if [ -z "$INPUT_IMAGE" ]; then
echo "Usage: favicon INPUT_IMAGE [OUTPUT_DIRECTORY]"
exit 1
fi
if [ -z "$OUTPUT_DIR" ]; then
OUTPUT_DIR="."
fi
if [ ! -d "$OUTPUT_DIR" ]; then
echo "Error: Output directory does not exist."
exit 1
fi
if ! [ -x "$(command -v convert)" ]; then
echo "Error: convert not found. Check if ImageMagick is installed. Get it from https://www.imagemagick.org." >&2
exit 1
fi
if [ -f $INPUT_IMAGE ]; then
echo "Generating favicons..."
SIZES=(16 32 57 72 114 144)
for size in ${SIZES[@]}; do
convert -flatten -background none -resize ${size}x${size} $INPUT_IMAGE $OUTPUT_DIR/favicon-${size}.png
if [ -f favicon-${size}.png ]; then
echo ">" favicon-${size}.png
else
echo "Error: Could not process input file. $INPUT_IMAGE may not be an image file."
exit 1
fi
done
echo "> favicon.ico"
convert -flatten -background none -resize 16x16 $INPUT_IMAGE $OUTPUT_DIR/favicon.ico
else
echo "Error: Input file does not exist."
exit 1
fi