Some Useful Scripts For Scanning

And Creating PDFs


Using scanimage from SANE, this bash script scans documents in batch mode to pnm image format, then processes the images with unpaper, netpbm tools, and Fred's ImageMagick scripts, and finally outputs the images as a multipage pdf or in various other formats (pnm, tif, ps, djvu) or spooled to printer.

Example Usage

  • Scan in grayscale mode a letter-sized document from ADF, then binarize using djvu wavelet compression, and save output to multipage pdf "outfile.pdf":
    $> bscan --mode=8-bit --shades=2 --page=Letter -BW outfile
  • Scan in truecolor mode a legal-sized document from ADF, then convert to DjVuPhoto encoded image before converting to pdf:
    $> bscan --mode=color --shades=truecolor --page=Legal \
    -c44 --djvutopdf=25 outfile

Defining Aliases

I find it useful to define some aliases for common tasks:
alias B='bscan --mode=8-bit --shades=2 --page=Letter --comp=lzw'
alias BL='bscan --mode=8-bit --shades=2 --page=Legal --comp=lzw'
alias BT='bscan --mode=color --shades=truecolor --page=Letter -c44 --djvutopdf=25'

Then to scan a letter-sized document to pdf using DjVu wavelet binarization:
$> B -BW outfile
or to scan & rotate the document 180 degrees:
$> B -BW --rotation=r180 outfile

More Examples

Run unpaper
$> B -BW -unpaper outfile

Don't scan, just process filename.%04d.pnm
$> B -BW -noscan filename

Scan with OCR
$> B -BW -ocr outfile


All configuration is done through ".bscanrc" placed in your $HOME folder.
Download sample .bscanrc