-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbooth.sh
executable file
·54 lines (42 loc) · 1.51 KB
/
booth.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
#!/bin/bash
action=$1
local_portrait_path="portraits"
upload_path="[email protected]:/home/vilmibm/public_html/asciigallery"
screenshot=00000001.png
final="$local_portrait_path/$(date --iso-8601=seconds -u).portrait"
function print () {
echo "printing..." >&2
lpr $final.txt
}
function upload () {
echo "uploading..." >&2
jp2a --height=30 --width=60 --output=$final.html --html --colors --fill /tmp/shotsmall.jpg
if [ ! -z $(ls index.html 2>/dev/null) ]; then
cp index.html index.html.bak
fi
cp index.top.html index.html
for portrait in $(ls $local_portrait_path | egrep "html$" | sort -r | head -n24); do
echo "<div class=\"portrait\">" >> index.html
echo $(tail -n +18 $local_portrait_path/$portrait | head -n +3 | perl -p -e 's/\n//') >> index.html
echo "<sub>$(echo $portrait | sed 's/.portrait.html//')</sub>" >> index.html
echo "</div>" >> index.html
done
echo "</div></body></html>" >> index.html
scp index.html $upload_path/
}
mplayer -vo png -frames 1 tv:// > /dev/null 2>/dev/null
convert $screenshot -gravity Center -crop 200x200+0+0 +repage /tmp/shotcrop.jpg > /dev/null
convert /tmp/shotcrop.jpg -scale 48x48 /tmp/shotsmall.jpg > /dev/null
jp2a --height=60 --width=80 --output=$final.txt --invert /tmp/shotsmall.jpg
cat $final.txt
if [ "$action" == "print" ]; then
print
elif [ "$action" == "upload" ]; then
upload
elif [ "$action" == "all" ]; then
print
upload
fi
rm $screenshot
rm /tmp/shotcrop.jpg
rm /tmp/shotsmall.jpg