linux:scanner_script

Scanning with linux

To use my scanner from linux I use the following script for quick scanning. Extremely convenient.

#!/bin/bash

if [ $# -lt 1 ]; then
	echo "Usage: $0 <docname>"
	exit 1
fi

CONVERT=/usr/bin/convert
IMG_FILE=$1
OUTIMG=${IMG_FILE}.jpg
SCANIMG=/usr/bin/scanimage

#scan document
echo -n "Start scanning, please wait"

$SCANIMG -p --resolution 150 -x 210 -y 297 > "$IMG_FILE"

#convert document
echo -n "Converting image"
$CONVERT  "$IMG_FILE" "$OUTIMG"
rm "$IMG_FILE"

Gnome Nautilus Script

Gnome has a function which enables you to execute scripts when right clicking your mouse on the desktop. Edit a file by

$ nano ~/.gnome2/nautilus-scripts/scanimage

and place the following code

#!/bin/bash

cd $NAUTILUS_SCRIPT_CURRENT_URI
exec gnome-terminal -e "/opt/scandoc new_image"
exit

Now remember to make the file runnable, and you are god to go.

chmod +x ~/.gnome2/nautilus-scripts/scanimage