Configuring Sane Image Scanner Support

The Only Thing that isn't Crazy is the Name

The leading package to interface with image scanning devices is called Sane. The project homepage is at http://www.mostang.com/sane/.

There are two categories for peripherals: those which can be attached and used almost immediately, and those which require much pulling out of hair. Mice and keyboards fall into the former group, and printers and scanners are definitely in the latter.

Of course, there is the predictable complexity of finely tuned machinery, carefully balanced color calibrations, and the myriad technical marvels of design which go into printers and scanners. Compounding this, however, is the absolute and total failure of manufacturers of printers and scanners to cooperate and create meaningful standards that have any chance at all of living up to their promises of "plug and play."

To match the insanity which is inherent in image scanning devices, the Sane project has applied a few more layers of confusing device drivers and meta-drivers and back-ends and front-ends. To the uninitiated, it can appear as a completely jumbled mess. To the initiated, it's slightly better.

Cutting to the meat of the matter, there are three major considerations to the Sane system to getting a working image scanning configuration.

This HOWTO will not bring order to chaos, but it can do two things. One, it can help a few users get their scanner working relatively quickly, if they're lucky to buy a late-model scanner that's similar to the author's. Two, it can point to a few filenames and pages which will help when it comes time to pull out the good old-fashioned web search engine for further information.

This HOWTO only walks through one configuration for one kind of device on both Red Hat Linux 7.3 (Valhalla) and Red Hat Linux 8.0 (Psyche). If you don't have the same device, improvise.

Is the Device Supported?

Go to the Sane project website at http://www.mostang.com/sane/, and check for support for your model of scanner. The list is growing constantly, but generally is far behind the available range of devices at the computer shop. If you don't have a scanner yet, take a printed copy of their website with you to see which models may be supported.

The scanner used here is a USB-only scanner, an Epson Perfection 1650, without the special "photo" backlighting lid for mounted slide scanning. Many other models are supported, but this one seems to have pretty good Sane support for the main flatbed features.

Detecting the Scanner

The quick and dirty utility sane-find-scanner has a list of a very large number of possibly supported scanner types, and will search known peripheral ports for them.

The most confusing part is that sane-find-scanner can often find a scanner that the rest of the software cannot. While the detector seems to be pretty reliable at many types of scanner, the rest of Sane's backend configuration is not as simple. At least the tool explicitly warns of this distinction when you run it.

Here's the example output of this utility on a USB scanner:

$ su -
# sane-find-scanner
# Note that sane-find-scanner will find any scanner that is connected
# to a SCSI bus and some scanners that are connected to the Universal
# Serial Bus (USB) depending on your OS. It will even find scanners
# that are not supported at all by SANE. It won't find a scanner that
# is connected to a parallel or proprietary port.

sane-find-scanner: found USB scanner (vendor = 0x04b8, product = 0x0110)
  at device /dev/usb/scanner0

This example, again, is my scanner. With a good reference chart, the "vendor = 0x04b8" would list Epson, and the "product = 0x0110" would be a Perfection 1650 model. Or some other scanner model with the exact same electronic innards.

The most important new information here is that it detected the device through the USB channel, through the device node at /dev/usb/scanner0.

Configuring Access to the Scanner

The challenge now will be to help Sane use that device on that port.

First, open up the permissions on that device to allow plain users of the system to access the scanner freely. Without these permissions, the software cannot communicate except as root.

$ su -
# ls -ld /dev/usb/scanner0
crw-------    1 halley   root     180,  48 Aug 30 19:31 /dev/usb/scanner0
# chmod a+rw /dev/usb/scanner0
# ls -ld /dev/usb/scanner0
crw-rw-rw-    1 halley   root     180,  48 Aug 30 19:31 /dev/usb/scanner0

Next, ensure the correct Sane backend driver for the scanner model is enabled in /etc/sane.d/dll.conf; this information is not provided by the sane-find-scanner but is listed in the main supported devices chart on the Sane project website.

For example, the 'epson' driver supports the Epson Perfection 1650 scanner, among others. Not all scanners match their backend driver name so predictably.

If the backend name has a # character to the left of it, remove that character.

/etc/sane.d/dll.conf (excerpt)
#dc210
#dc240
dmc
epson
fujitsu
hp

Note: some devices can conflict with each other, and allowing Sane to attempt to connect with the wrong backend driver can freeze, hang, crash the process, or wedge the whole machine unpredictably. These are due to bad hardware designs; proper hardware should not react badly when given incorrect detection data. (So much for "plug and play.") For example, if the 'frobnitz' backend and the 'bleetwort' backend conflicted, then only one of them should be enabled in the /etc/sane.d/dll.conf file. Insert a # character to disable the unused conflicting driver type. Such cases are documented on the Sane website and in some backend files.

Lastly, each backend driver also has its own configuration file in the /etc/sane.d directory. In this file, variations in each backend driver can be adjusted. Disable unnecessary lines with the # character, and enable the required lines, in the same way shown for the previous main file.

For the 'epson' backend driver, there is a file called /etc/sane.d/epson.conf and it must be reviewed. Here, we disable the SCSI option and enable the correct USB option.

/etc/sane.d/epson.conf (excerpts)
# SCSI scanner:
#scsi EPSON
[...]
# USB scanner - only enable this if you have an EPSON scanner.
#usb /devusb/scanner0
usb /dev/usb/scanner0

That should be all it takes to get a scanner going, so now it's time to try some front-end software. While it's easy to use a powerful visual interface like XSane, we'll check the configuration with a quick query with the command-line.

$ scanimage -L
device `epson:/dev/usb/scanner0' is a Epson GT-8200 flatbed scanner
$ scanimage -d epson:/dev/usb/scanner0 >/dev/null

The scanimage tool has a huge number of options. Note the internal detection routines might not even get the scanner model right, though these models may have identical electronics. Try --help to get started if you really want to use this tool for real scanning. The above commands merely try a test scan and discard the image data.



Contact Ed Halley by email at ed@halley.cc.
Text, code, layout and artwork are Copyright © 1996-2005 Ed Halley.
Copying in whole or in part, with author attribution, is expressly allowed.
Any references to trademarks are illustrative and are controlled by their respective owners.
Make donations with PayPal - it's fast, free and secure!