-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgif.sh
executable file
·161 lines (126 loc) · 4.08 KB
/
gif.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
#!/bin/bash
# Create GIF that are less than 2 MB
# This was used back when Imgur didn't allow GIFs bigger than 2 MB
function check
{
du -h $nomgif.gif
RESULTS_SIZE=`stat -c %s "$nomgif.gif"`
if [ "$RESULTS_SIZE" -le 2087643 ]
then
echo "OK !"
rm $nom*.$extension
rm $nom.gif
rm -r $nom
exit
fi
(( i++ ))
nomgif="${nom}_${i}"
echo ""
}
nom=$1
i="1"
nomgif="${nom}_${i}"
fuzz="2%"
if [ -f "mask.png" ]
then
echo "Utilisation du masque..."
for fichierMasque in `ls ${nom}*.jpg`
do
echo "Application du masque à $fichierMasque..."
composite -compose Dst_In mask.png $fichierMasque -alpha Set ${fichierMasque%.jpg}.png
done
mogrify -format png ${nom}0000.jpg
extension="png"
rm ${nom}*.jpg
rm mask.png
echo ""
else
extension="jpg"
fi
echo "Création du GIF $1"
rm $1
mkdir $1
echo ""
echo "Fuzz 0% - 1280x720"
convert -layers OptimizeTransparency -fuzz "0%" -delay 6 -loop 0 $1*.$extension $1.gif
gifsicle -w -O3 -d 4 $1.gif > $nomgif.gif
check
echo "Fuzz $fuzz - 1280x720"
convert -layers OptimizeTransparency -fuzz "$fuzz" -delay 6 -loop 0 $1*.$extension $1.gif
gifsicle -w -O3 -d 4 $1.gif > $nomgif.gif
check
echo "Fuzz 0% - 1280x720 - 256 couleurs"
gifsicle -w -O3 -d 4 --colors 256 $1.gif > $nomgif.gif
check
echo "Fuzz $fuzz - 1280x720 - 256 couleurs"
gifsicle -w -O3 -d 4 --colors 256 $1.gif > $nomgif.gif
check
echo "Redimensionnement..."
mogrify -resize 640x360 $1*.$extension
echo ""
echo "Fuzz 0% - 640x360"
convert -layers OptimizeTransparency -fuzz "0%" -delay 6 -loop 0 $1*.$extension $1.gif
gifsicle -w -O3 -d 4 $1.gif > $nomgif.gif
check
echo "Fuzz $fuzz - 640x360"
convert -layers OptimizeTransparency -fuzz "$fuzz" -delay 6 -loop 0 $1*.$extension $1.gif
gifsicle -w -O3 -d 4 $1.gif > $nomgif.gif
check
echo "Fuzz 0% - 640x360 - 256 couleurs"
gifsicle -w -O3 -d 4 --colors 256 $1.gif > $nomgif.gif
check
echo "Fuzz $fuzz - 640x360 - 256 couleurs"
gifsicle -w -O3 -d 4 --colors 256 $1.gif > $nomgif.gif
check
echo "Fuzz 0% - 640x360 - Division du nombre de frames par 2"
mv $1???[13579].$extension $1
convert -layers OptimizeTransparency -fuzz "0%" -delay 6 -loop 0 $1*.$extension $1.gif
gifsicle -w -O3 -d 8 $1.gif > $nomgif.gif
check
echo "Fuzz 0% - 640x360 - Division du nombre de frames par 2 - 256 couleurs"
gifsicle -w -O3 -d 8 --colors 256 $1.gif > $nomgif.gif
check
echo "Fuzz $fuzz - 640x360 - Division du nombre de frames par 2"
convert -layers OptimizeTransparency -fuzz "$fuzz" -delay 6 -loop 0 $1*.$extension $1.gif
gifsicle -w -O3 -d 8 $1.gif > $nomgif.gif
check
echo "Fuzz $fuzz - 640x360 - Division du nombre de frames par 2 - 256 couleurs"
gifsicle -w -O3 -d 8 --colors 256 $1.gif > $nomgif.gif
check
echo "Fuzz 0% - 384x216"
mv $1/* .
echo "Redimensionnement..."
mogrify -resize 384x216 $1*.$extension
echo "Création du GIF..."
convert -layers OptimizeTransparency -fuzz "0%" -delay 6 -loop 0 $1*.$extension $1.gif
gifsicle -w -O3 -d 4 $1.gif > $nomgif.gif
check
echo "Fuzz 0% - 384x216 - 256 couleurs"
gifsicle -w -O3 -d 4 --colors 256 $1.gif > $nomgif.gif
check
echo "Fuzz $fuzz - 384x216"
convert -layers OptimizeTransparency -fuzz "$fuzz" -delay 6 -loop 0 $1*.$extension $1.gif
gifsicle -w -O3 -d 4 $1.gif > $nomgif.gif
check
echo "Fuzz $fuzz - 384x216 - 256 couleurs"
gifsicle -w -O3 -d 4 --colors 256 $1.gif > $nomgif.gif
check
echo "Fuzz 0% - 384x216 - Division du nombre de frames par 2"
mv $1???[13579].$extension $1
convert -layers OptimizeTransparency -fuzz "0%" -delay 6 -loop 0 $1*.$extension $1.gif
gifsicle -w -O3 -d 8 $1.gif > $nomgif.gif
check
echo "Fuzz 0% - 384x216 - Division du nombre de frames par 2 - 256 couleurs"
gifsicle -w -O3 -d 8 --colors 256 $1.gif > $nomgif.gif
check
echo "Fuzz $fuzz - 384x216 - Division du nombre de frames par 2"
convert -layers OptimizeTransparency -fuzz "$fuzz" -delay 6 -loop 0 $1*.$extension $1.gif
gifsicle -w -O3 -d 8 $1.gif > $nomgif.gif
check
echo "Fuzz $fuzz - 384x216 - Division du nombre de frames par 2 - 256 couleurs"
gifsicle -w -O3 -d 8 --colors 256 $1.gif > $nomgif.gif
check
echo "Ficher trop grand - Abandon"
rm $1*.$extension
rm $1.gif
rm -r $1