-
Notifications
You must be signed in to change notification settings - Fork 0
/
convert.sh
executable file
·66 lines (54 loc) · 1.04 KB
/
convert.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
#!/bin/bash
set -eu
if [ $# -ne 1 ]
then
echo 'You must specify sticker set ID!'
exit 1
fi
set_id=$1
l2t_dir=$(dirname $(realpath "${BASH_SOURCE}"))
. "${l2t_dir}/globals.sh"
function clear_dir ()
{
\rm -rf "${conv_dir}"
mkdir -p "${conv_dir}"
}
function enum_imgs ()
{
imgs=("${resi_dir}/"*.webp)
# only install anim_dump if we actually have webp files
if [ ${#imgs[@]} -gt 0 ]
then
setup_animdump
fi
imgs+=("${resi_dir}/"*.png)
}
function print_imgs ()
{
for (( i=0; i<${#imgs[@]} ; i++ ))
do
echo ${imgs[i]}
done
}
function convert_imgs ()
{
batch_size=$(nproc)
echo "Starting batch conversion on ${batch_size} threads... "
j=0
set +e
(
for (( i=0; i<${#imgs[@]} ; i++ ))
do
((j=j%batch_size)); ((j++==0)) && wait
img_file=$(basename "${imgs[i]}")
convert_img_webm "${imgs[i]}" "${conv_dir}/${img_file%.*}.webm" &
done
wait
)
set -e
echo -e "\nBatch conversion done."
}
clear_dir
enum_imgs
#print_imgs
convert_imgs