Console utilities in Linuxes are cool: mcabber for jabber, mutt for mail, mocp for music, vim to rule them all! This note is about scaning from the console (I assume your scanner is already set-up). Aim is to scan document with good quality into pdf with reasonable size.

Scanning is done by scanimage utility:

scanimage --resolution 300 --mode Color --format tiff > document.tiff

If there is more than one scanner in your system, list them all by scanimage -L commant and use specify name with --device-name argument.

Next step is to convert tiff into pdf image. It can be done with imagemagick:

convert document.tiff document-big.pdf

But resulting pdf is too big and must be reduced. I’ve found shrinkpdf bash script very helpful for this purpose with correction: IMHO 72 DPI resolution is too small, so I’ve changed it to 300 dpi. Essential part of that script is ghostscript call:

gs -q -dNOPAUSE -dBATCH -dSAFER        \
   -sDEVICE=pdfwrite                   \
   -dCompatibilityLevel=1.3            \
   -dPDFSETTINGS=/screen               \
   -dEmbedAllFonts=true                \
   -dSubsetFonts=true                  \
   -dColorImageDownsampleType=/Bicubic \
   -dColorImageResolution=300          \
   -dGrayImageDownsampleType=/Bicubic  \
   -dGrayImageResolution=300           \
   -dMonoImageDownsampleType=/Bicubic  \
   -dMonoImageResolution=300           \
   -sOutputFile=document.pdf           \