#!/bin/bash # asciiview - an ascii art image browser script. Front end for aview/aaflip clear() { kill $! 2>/dev/null if [ -n $ATMPDIR -a -d $ATMPDIR ]; then rm -f $ATMPDIR/aview$$.pgm 2>/dev/null && rmdir $ATMPDIR 2>/dev/null else echo "Cannot remove temporary directory $ATMPDIR" exit 1 fi } myconvert() { if anytopnm $1 >$ATMPDIR/aview$$.pgm 2>/dev/null ; then exit elif convert -colorspace gray $1 pgm:- 2>/dev/null ; then exit fi echo "Failed to convert file format to PNM by both convert and anytopnm" >&2 while true; do echo "0 " done } filenames="" options="" if [ "$1" = "" ]; then echo "$0 - an ascii art image/animation browser. To run this script you need aview, aaflip and NetPBM or ImageMagick. You may browse any graphics format supported by NetPBM or ImageMagick and .fli/.flc files. Usage: $0 [options] [filenames] type aview --help [enter] for list of options. " exit 1 fi while [ "$1" != "" ]; do case $1 in "-font" | "-driver" | "-kbddriver" | "-mousedriver" | "-*width" | "-*height" | "-bright" | "-contrast" | "-gamma" | "-random" | "-dimmul" | "-boldmul") options="$options $1 $2" shift shift ;; -*) options="$options $1" shift ;; *) filenames="$filenames $1" shift ;; esac done ATMPDIR=`mktemp -d` || exit 1 trap clear 0 mkfifo $ATMPDIR/aview$$.pgm outfile=$ATMPDIR/aview$$.pgm for name in $filenames ; do if test -r $name ; then case $name in *.fli | *.lfc | *.flic ) PATH="$PATH:." aaflip $options $name ;; *) myconvert $name >$ATMPDIR/aview$$.pgm & pid=$! PATH="$PATH:." aview $options $ATMPDIR/aview$$.pgm kill $pid 2>/dev/null esac else echo "$name could not be opended" fi done