-
Notifications
You must be signed in to change notification settings - Fork 1
/
mkgif
executable file
·66 lines (53 loc) · 1.36 KB
/
mkgif
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/ksh
# Automate making gifs
# by Benjamin Elijah Griffin 24 Sep 1999
usage () {
cat <<EndUsage
$0: usage
$0 [options] file1 [file2 ...]
Options
-b N use N bits per pixel (default 8, max 8)
-t COL make color COL transparent
-s use simpler output file names
Colors can be specified as
r/b/g decimal numbers
r,b,g decimal numbers
#rrbbgg hex numbers
The files by default will be saved with an extension that indicates
the number of bits used and '.gif'.
EndUsage
exit
}
bits=8
trans=
simple=no
loop=yes
while [ X$loop != X ] ; do
case "$1" in
-b) shift; bits=$1; shift ;;
-t) shift; trans="-transparent $1"; shift ;;
-s) shift; simple=yes ;;
--help) usage ;;
-*) echo "$1 unrecognized option"; usage ;;
'') echo "Insufficent arguments"; usage ;;
*) loop= ;;
esac
done
if [ $simple = no ] ; then
ex=-${bits}b.gif
else
ex=.gif
fi
quant=`echo 2^$bits | bc`
for each ; do
case $each in
*.tif|*.tiff) new=${each%%.tif*}$ex ; tool=tifftopnm ;;
*.jpg|*.jpeg) new=${each%%.jp*g}$ex ; tool=djpeg ;;
*.gif) new=${each%%.gif}$ex ; tool=giftopnm ;;
*.p[bgpn]m) new=${each%%.p[bgpn]m}$ex ; tool=cat ;;
*.xcf) echo "Skipping $each (no .xcf converter)" ; next ;;
*.*) new=${each%.*}$ex ; tool=anytopnm ;;
esac
$tool $each | ppmquant $quant | ppmtogif $trans > $new
echo $new done
done