-
Notifications
You must be signed in to change notification settings - Fork 1
/
png-press.sh
executable file
·49 lines (39 loc) · 983 Bytes
/
png-press.sh
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
45
46
47
#!/bin/bash
if [ -z "$1" ]
then
echo -e $'\e[31m
No input directory set.
Usage :
png_press.sh ${input directory full path} ${output directory full path}'
echo $'\e[0m'
exit
fi
if [ -z "$2" ]
then
echo -e $'\e[31m
No output directory set.
Usage :
png_press.sh ${input directory full path} ${output directory full path}'
echo $'\e[0m'
exit
fi
if ! type zopflipng>/dev/null 2>&1; then
echo "zopfli not found in this machine \n" 1>&2
git clone https://github.com/google/zopfli.git
cd zopfli
make zopflipng
directory=${PWD}
if grep -q 'export PATH="'${directory}':$PATH"' ~/.bash_profile; ##note the space after the string you are searching for
then
echo "zopflipng is available on path"
else
echo $'\nexport PATH="'${directory}':$PATH"' >>~/.bash_profile
fi
else
echo "zopflipng found in this machine"
fi
mkdir -p $2
for file in "$1"/*.png
do
zopflipng "${file}" -m $2/$(basename "${file}")
done