-
Notifications
You must be signed in to change notification settings - Fork 0
/
typ2png4reveal.sh
59 lines (44 loc) · 1.08 KB
/
typ2png4reveal.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
#! bin/bash
# Compiles .typ files from `typ-games` to .png
# place in sub-dir `/png-games/`, then
# IM-convert to transparent and place in `imgs/`
## cleans pdfs that might be hanging around in `typ-games/`
while getopts "n:mwk" opt; do
case $opt in
n) # week num
WEEK=$OPTARG;;
m) # mon, binary
wDECK="mon-deck";;
w) # wed, binary
wDECK="wednes-deck";;
k) # keep png-games/*?
KEEP=true;;
esac
done
: ${wDECK:="wednes-deck"}
: ${KEEP:=false}
: ${WEEK:=5}
# cd lecture-slides/wk-5/mon-deck/typ-games/;
# cd lecture-slides/wk-5/wednes-deck/typ-games/;
cd "lecture-slides/wk-${WEEK}/${wDECK}/typ-games/";
for f in ./*.typ; do
FNAME=${f%.typ};
if [ -f ${FNAME}.pdf ]; then
typst c -f png --ppi 600 ${f} ${FNAME}.png;
mv ${FNAME}.png ./png-games/;
convert "./png-games/${FNAME}.png" -transparent white "../imgs/${FNAME}.png";
rm ${FNAME}.pdf;
fi
done
# && -z "$(ls -A ./png-games/)"
if [ ! $(${KEEP}) ]; then
rm -f ./png-games/*;
fi
# for f in ./*.pdf; do
# if [ -f ${f} ]; then
# rm ${f};
# fi
# done
# for f in png-games/*.png;
# do convert "${f#/}" -transparent white "../imgs/${f#*/}";
# done