Script for easy scanning with a Samsung SCX-4521F

For Linux Mint 16. Requires SULDR, scanimage, imagemagick.

/usr/bin/scanit:

#!/bin/bash
#syntax is:
echo "scanit <filename> <dpi>"
sudo scanimage --resolution $2 >/tmp/andris-scan.pnm
#correct faulty pnm produced by scanimage by removing the first 54 bytes
sudo dd if=/tmp/andris-scan.pnm of=/tmp/andris-scan-corr.pnm bs=54 skip=1
#we had to scan with root privileges, but we want to access it with a regular user 
sudo chown `whoami` /tmp/andris-scan.pnm
convert /tmp/andris-scan-corr.pnm /tmp/andris-scan.png
cp /tmp/andris-scan.png $1
sudo rm /tmp/andris-scan.pnm /tmp/andris-scan-corr.pnm /tmp/andris-scan.png

Add new comment