#!/bin/sh # Printer script for printing graphics files via Ghostscript # # Copyright 1997 by Michael J. Hammel # Use it as you wish - and at your own risk. # Requirements: # 1. The NetPBM tools must be installed on your system and the various # tools must be in your path. # 2. Your print spooler knows how to print to a printer called # lpps-high. # Configuration: # Simply put this script in some directory in your path (say # /usr/local/bin) and make symbollic links from it to: # print-gif.sh # print-ppm.sh # Make sure this script is executable! # # Note: this script requires that the print spooler be set up using # the printcap file found in the July 1997 issue of the Graphics Muse in # the Linux Gazette. # Default: an EPSON ESC/P2 printer # possible resolutions for EPSON ESC/P2 printers: # 1: low res 1 ( 180x180 ) # 2: low res 2 ( 180x360 ) # 3: high res 1 ( 360x180 ) - this resolution is unsupported by the printer. # 4: high res 2 ( 360x360 ) dpi=360 # Default height and width of the paper to be printed on height="11" width="8.5" # Default scale setting scale=1.0 USAGE=" `basename $0` [ -d dpi | -t turn-type | -w paper-width | -h paper-height ] filename.[gif|tga|ppm] where NetPBM Specific settings: DPI Dots Per Inch (default: $dpi) paper-width width of paper (inches) (default: $width) paper-heigth height of paper (inches) (default: $height) turn-type either "turn" to force image to be rotated 90 degrees or "noturn" to force image to not be turned (pnmtops may try to turn the image if it things the image won't fit on the page) This script can handle tga as print-tga.sh gif as print-gif.sh ppm as print-ppm.tga It also requires that NetPBM has been installed and that the printer spooler knows how to print the graphics files (probably using Ghostscript). " #============================================================================ # Nothing below here should need to be changed, unless you have a problem # getting the output from gs to your printer port. #============================================================================ # Determine how this script was called. scriptname=`basename $0` # check the passed arguments for validity and set variables accordingly if [ $# -ne 0 ] then while getopts :d:w:h:s:t: args do case $args in d) dpi=$OPTARG;; w) width=$OPTARG;; h) height=$OPTARG;; s) scale=$OPTARG;; t) turn_type=$OPTARG;; *) echo "Invalid option" echo "$USAGE" exit 1;; esac done shift `expr $OPTIND - 1` fi echo "Height: $height" echo "Width: $width" echo "Turn_type: $turn_type" echo "dpi: $dpi" echo "scale: $scale" # exit 0 if [ "$turn_type" != "turn" -a "$turn_type" != "noturn" ] then echo "The only valid values the -t option are \"turn\" and \"noturn\"" echo "$USAGE" exit 1 else turn_type="-$turn_type" fi case $scriptname in "print-tga.sh") tgatoppm $1 | pnmtops $turn_type -scale $scale -dpi ${dpi} \ -width ${width} -height ${height} | lpr -Plpps-high ;; "print-gif.sh") giftopnm $1 | pnmtops $turn_type -scale $scale -dpi ${dpi} \ -width ${width} -height ${height} | lpr -Plpps-high ;; "print-ppm.sh") pnmtops $turn_type -scale $scale -dpi ${dpi} -width ${width} \ -height ${height} $1 | lpr -Plpps-high ;; esac exit 0