-
Notifications
You must be signed in to change notification settings - Fork 0
/
insta.sh
executable file
·73 lines (61 loc) · 1.48 KB
/
insta.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
#!/bin/bash
set -eu
if [ $# -lt 1 ]
then
echo 'You must specify sticker pack ID!'
exit 1
fi
set_id=$1
l2t_dir=$(dirname $(realpath "${BASH_SOURCE}"))
. "${l2t_dir}/globals.sh"
function clear_dir ()
{
\rm -rf "${conv_dir}"
\rm -rf "${trim_dir}"
\rm -rf "${resi_dir}"
\rm -rf "${fuzz_dir}"
mkdir -p "${conv_dir}"
mkdir -p "${trim_dir}"
mkdir -p "${resi_dir}"
mkdir -p "${fuzz_dir}"
}
function convert_jpgs ()
{
for (( i=0; i<${#jpgs[@]} ; i++ ))
do
jpg_file=$(basename "${jpgs[i]}")
echo -n "Converting ${jpg_file}... "
convert_jpg "${jpgs[i]}" "${conv_dir}/${jpg_file%.*}.png"
echo "done."
done
}
function trim_pngs ()
{
for (( i=0; i<${#pngs[@]} ; i++ ))
do
png_file=$(basename "${pngs[i]}")
echo -n "Trimming ${png_file}... "
convert "${pngs[i]}" -fuzz 1% -trim "${trim_dir}/${png_file}"
echo "done."
done
}
function fuzz_pngs ()
{
local i
for (( i=0; i<${#pngs[@]} ; i++ ))
do
png_file=$(basename "${pngs[i]}")
fuzz_png "${pngs[i]}" "${fuzz_dir}"
done
}
clear_dir
jpgs=("${orig_dir}/"*.jpg)
# make sure to only run if files are actually there
find "${orig_dir}/" -name '*.jpg' -type f | grep . && convert_jpgs
find "${orig_dir}/" -name '*.png' -type f | grep . && cp "${orig_dir}/"*.png "${conv_dir}"
pngs=("${conv_dir}/"*.png)
trim_pngs
pngs=("${trim_dir}/"*.png)
fuzz_pngs
pngs=("${fuzz_dir}/"*.png)
resize_pngs "${resi_dir}" "${pngs[@]}"