1#!/bin/sh
2# asciiview - an ascii art image browser script. Front end for aview/aaflip
3clear()
4{
5  kill $! 2>/dev/null
6  rm -f /tmp/aview$$.pgm 2>/dev/null
7}
8myconvert()
9{
10   if anytopnm $1 >/tmp/aview$$.pgm 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}
20filenames=""
21options=""
22if [ "$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
35fi
36while [ "$1" != "" ]; do
37  case $1 in
38    "-font" | "-driver" | "-kbddriver" | "-mousedriver" | "-*width" | "-*height" | "-bright" | "-contrast" | "-gamma" | "-random" | "-dimmul" | "-boldmul")
39      options="$options $1 $2"
40      shift
41      shift
42      ;;
43    -*)
44      options="$options $1"
45      shift
46      ;;
47    *)
48      filenames="$filenames $1"
49      shift
50      ;;
51  esac
52done
53trap clear 0
54mkfifo /tmp/aview$$.pgm
55outfile=/tmp/aview$$.pgm
56for name in $filenames ; do
57if test -r $name ; then
58case $name in
59*.fli | *.lfc | *.flic )
60  PATH="$PATH:."
61  aaflip $options $name
62  ;;
63*)
64  myconvert $name >/tmp/aview$$.pgm &
65  pid=$!
66  PATH="$PATH:."
67  aview  $options /tmp/aview$$.pgm
68  kill $pid 2>/dev/null
69esac
70else
71  echo "$name could not be opended"
72fi
73done
74