fix Port-O-Launch
[divverent/nexuiz.git] / misc / brightspot.sh
1 #!/bin/sh
2
3 if [ -z "$1" ]; then
4         echo>&2 "Usage: $0 foo_rt.jpg"
5         exit 1
6 fi
7
8 brightspot=
9 if which brightspot-bin >/dev/null; then
10         brightspot=brightspot-bin
11 else
12         case "$0" in
13                 */*)
14                         mydir=${0%/*}
15                         ;;
16                 *)
17                         mydir=.
18                         ;;
19         esac
20         brightspot="$mydir/brightspot-bin"
21         [ "$brightspot" -nt "$mydir/brightspot.c" ] || gcc -lm -O3 -Wall -Wextra "$mydir/brightspot.c" -o "$brightspot" || exit 1
22 fi
23
24 i=$1
25 ext=${i##*.}
26 name=${i%.*}
27 name=${name%_[rlbfud][tfktpn]}
28
29 {
30         convert "$name"_rt."$ext" -depth 8 -geometry 512x512 GRAY:-
31         convert "$name"_lf."$ext" -depth 8 -geometry 512x512 GRAY:-
32         convert "$name"_bk."$ext" -depth 8 -geometry 512x512 GRAY:-
33         convert "$name"_ft."$ext" -depth 8 -geometry 512x512 GRAY:-
34         convert "$name"_up."$ext" -depth 8 -geometry 512x512 GRAY:-
35         convert "$name"_dn."$ext" -depth 8 -geometry 512x512 GRAY:-
36 } | "$brightspot" /dev/stdin