Tuesday, January 20, 2015

Photocopier - Proof of Concept

I was asked to photocopy something for someone and so I decided, given the state of my MFC (Multi-Function Center - photocopier, fax, printer) device, I'd do it using a scanner and printer. The reasoning for this is that I can, eventually, use a Raspberry Pi and it's GPIO to give me a modular, extensible photocopier.

Extensible? you ask... well... It occurred to me that I only have a flatbed scanner, but at some stage, I might want to add a multipage scanner. Or I might want to switch to a colour printer (though my black and white, very fast, laser printer does me quite well for the time being). Or I might want to add a display of some description and have a scan to email facility. And if there's a display anyway, then the ability to print off multiple copies would be brilliant.

So, on my desktop computer, I put together this script. All I need to do is to set up a Raspberry Pi with Raspian, hook up a button to the GPIO, and have it run this script whenever the button is pushed. Oh, and probably have a blinky LED to tell the user when the scanner is still scanning...

 WIDTH_INCHES="$( echo "scale=3;$WIDTH_MM/25.4" | bc )"
 HEIGHT_INCHES="$( echo "scale=3;$HEIGHT_MM/25.4" | bc )"
 SCAN_PARAMETERS="--mode Gray -l 0 -t 0 -x $WIDTH_MM -y $HEIGHT_MM --resolution $RESOLUTION"  
 photocopy_cmd="$SCAN_COMMAND -d $SCAN_DESTINATION $SCAN_PARAMETERS | pnmtops -width $WIDTH_INCHES -height $HEIGHT_INCHES -imagewidth $WIDTH_INCHES -imageheight $HEIGHT_INCHES | lp -d $PRINTER"
 eval $photocopy_cmd  

If this script is going to be used by anyone else:
  • You need to have sane and cups installed.
  • To get the printer name run:
    • scanimage -L
  • To get the printer name run:
    • lpstat -p -d
  • The dimensions (WIDTH_MM and HEIGHT_MM) are obviously in millimeters (the dimensions there are for A4). It does a conversion to inches (damn Americans and their imperial system).
  • If you want colour copies, in SCAN_PARAMETERS change:
    • --mode Gray
    • to
    • --mode Color
  • If you're finding it slow, trying turning down the resolution (though 150 seems to be a pretty good setting).
I'm planning on running this on a Raspberry Pi which I'll have set up with my tv server (I suspect I've found my problem with that though need to do some testing - for which I've had to order a couple of parts).

No comments:

Post a Comment