Debian Codegraph @

asciiview

raw ◀ ▶
2 Debian patches touch this file
1 #!/bin/bash
2 # asciiview - an ascii art image browser script. Front end for aview/aaflip
3 clear()
4 {
5 kill $! 2>/dev/null
•6 rm -rf $tmpdir 2>/dev/null
7 }
8 myconvert()
9 {
•10 if anytopnm "$1" >"$2" 2>/dev/null ; then
11 exit
•12 elif convert -colorspace gray "$1" pgm:- 2>/dev/null ; then
13 exit
14 fi
15 echo "Failed to convert file format to PNM by both convert and anytopnm" >&2
16 while true; do
17 echo "0 "
18 done
19 }
20 filenames=""
21 options=""
22 if [ "$1" = "" ]; then
23 echo "$0 - an ascii art image/animation browser.
24
25 To run this script you need aview, aaflip and NetPBM or ImageMagick.
26 You may browse any graphics format supported by NetPBM or ImageMagick
27 and .fli/.flc files.
28
29 Usage:
30 $0 [options] [filenames]
31
32 type aview --help [enter] for list of options.
33 "
34 exit 1
35 fi
•36 counter=0
37 while [ "$1" != "" ]; do
•38 case "$1" in
39 "-font" | "-driver" | "-kbddriver" | "-mousedriver" | "-*width" | "-*height" | "-bright" | "-contrast" | "-gamma" | "-random" | "-dimmul" | "-boldmul")
40 options="$options $1 $2"
41 shift
42 shift
43 ;;
44 -*)
45 options="$options $1"
46 shift
47 ;;
48 *)
•49 filenames[$counter]="$1"
50 counter=$(($counter+1))
51 shift
52 ;;
53 esac
54 done
55 trap clear 0
•56 tmpdir=`mktemp -t -d`
57 outfile=$tmpdir/aview.pgm
•58 mkfifo $outfile
59 while [ $counter -gt 0 ]; do
60 counter=$(($counter-1))
61 name=${filenames[$counter]}
62 if test -r "$name" ; then
63 case "$name" in
64 *.fli | *.lfc | *.flic )
65 PATH="$PATH:."
•66 aaflip $options "$name"
67 ;;
68 *)
•69 myconvert "$name" "$outfile" >"$outfile" &
70 pid=$!
71 PATH="$PATH:."
•72 aview $options $outfile
73 kill $pid 2>/dev/null
74 esac
75 else
•76 echo "The file '$name' could not be opened."
77 fi
78 done