#!/bin/sh
# copier - scan page and immediately print it
#          Any command-line options are passed to scanimage,
#          so see the scanimage(1) man page and "scanimage -h"
#          for details
#
# Rob Funk <funk+@osu.edu>
# 21 May, 2000
#
# This is much slower than a real copier, is very processor-bound,
# and will take around 20MB per page in the print spool, so make sure
# /var/spool has plenty of disk space.
#
# pnmtops will downscale the image to fit the printed page if original
# width and height are too big.  Unfortunately, I haven't found a way
# to tell it to print exactly what the original looks like, so the output
# size will be a bit off from input size.  This makes the resolution
# setting less useful than it could be.  Also, the RLE compression that
# pnmtops uses doesn't do very well at compressing scanned images (to
# take up less space in the print spool), but it's better than nothing.

DEVICE=umax
RES=360		# My Canon printer is 360 dpi; use 300 for HP
# Mode is either Color, Gray, or Lineart
MODE=Gray
# page measurements in millimeters
left=0
top=0
width=215.9
height=279.4	# 11" tall page
#height=355.6	# 14" tall page

echo "Scanning...."
scanimage -d $DEVICE \
	--mode $MODE \
	--resolution $RES \
	-l $left -t $top \
	-x $width -y $height \
	--quality-cal=yes \
	"$@" \
	| pnmtops -scale 0.19 -dpi $RES \
		-width 8.5 -height 11 -nocenter -rle \
	| lpr && echo "Printing..."
