]> git.plutz.net Git - stereofy/blob - stereofy.sh
initial commit
[stereofy] / stereofy.sh
1 #!/bin/sh
2
3 algo="d"   #algorythm, Dubois by default
4 model="gm" #color model, green-magenta by default
5 param=""   #leave blank, will be -$algo$model
6 left=''
7 right=''
8 stereo=''
9
10 while [ -n "$1" ]; do
11   case "$1" in
12     -d|--dubois]) algo="d"
13         ;;
14     -f|--full|--full-color]) algo="f"
15         ;;
16     -h|--half|--half-color]) algo="d"
17         ;;
18     -rc|--rc|--red-cyan) model="rc"
19         ;;
20     -mc|--mc|--magenta-cyan) model="mc"
21         ;;
22     -gm|--gm|--green-magenta) model="gm"
23         ;;
24     -ab|--ab|--amber-blue|yellow-blue) model="ab"
25         ;;
26     -[dfh]rc|-[dfh]gm|-[fd]mc|-dab) param="$1"
27         ;;
28     *)  if [ -z "$left" ]; then
29           left="$1"
30         elif [ -z "$right" ]; then
31           right="$1"
32         elif [ -z "$stereo" ]; then
33           stereo="$1"
34         fi
35         ;;
36   esac
37   shift 1;
38 done
39
40 [ -z "$param" ] && param="-$algo$model"
41 [ -z "$stereo" ] && stereo="${left}_stereo.jpg"
42
43 geom=$(identify "$left" |sed -rn 's:^.* ([0-9]+x[0-9]+) .*$:\1:gp')
44
45 echo -n bitmapping...
46 stream "$left" "$left.bts"
47 stream "$right" "$right.bts"
48
49 echo -n anaglyphing...
50 anaglyph "$param" "$left.bts" "$right.bts" "$stereo.bts"
51
52 if [ $? = 0 ]; then
53   echo -n converting...
54   convert -depth 8 -size "$geom" "rgb:$stereo.bts" "$stereo"
55 fi
56
57 echo cleaning...
58 rm "$left.bts" "$right.bts" "$stereo.bts" 2>/dev/null