7.7.Â Image Scanners

Written by MarcFonvieille.

In FreeBSD, access to image scanners is provided by
SANE (Scanner Access Now Easy), which
is available in the FreeBSD Ports Collection.
SANE will also use some FreeBSD device
drivers to provide access to the scanner hardware.

FreeBSD supports both SCSI and
USB scanners. Depending upon the scanner
interface, different device drivers are required. Be sure the
scanner is supported by SANE prior
to performing any configuration. Refer to
http://www.sane-project.org/sane-supported-devices.html
for more information about supported scanners.

This chapter describes how to determine if the scanner has
been detected by FreeBSD. It then provides an overview of how to
configure and use SANE on a FreeBSD
system.

7.7.1.Â Checking the Scanner

The GENERIC kernel includes the
device drivers needed to support USB
scanners. Users with a custom kernel should ensure that the
following lines are present in the custom kernel configuration
file:

device usb
device uhci
device ohci
device ehci

To determine if the USB scanner is
detected, plug it in and use dmesg to
determine whether the scanner appears in the system message
buffer. If it does, it should display a message similar to
this:

ugen0.2: <EPSON> at usbus0

In this example, an EPSON
PerfectionÂ®Â 1650
USB scanner was detected on
/dev/ugen0.2.

If the scanner uses a SCSI interface,
it is important to know which SCSI
controller board it will use. Depending upon the
SCSI chipset, a custom kernel configuration
file may be needed. The GENERIC kernel
supports the most common SCSI controllers.
Refer to /usr/src/sys/conf/NOTES to
determine the correct line to add to a custom kernel
configuration file. In addition to the
SCSI adapter driver, the following lines
are needed in a custom kernel configuration file:

The output should show the interface type of the scanner
and the device node used to attach the scanner to the system.
The vendor and the product model may or may not appear.

Note:

Some USB scanners require firmware to
be loaded. Refer to sane-find-scanner(1) and sane(7) for
details.

Next, check if the scanner will be identified by a
scanning frontend. The SANE
backends include scanimage which can be
used to list the devices and perform an image acquisition.
Use -L to list the scanner devices. The
first example is for a SCSI scanner and the
second is for a USB scanner:

In this second example,
'epson2:libusb:/dev/usb:/dev/ugen0.2' is
the backend name (epson2) and
/dev/ugen0.2 is the device node used by the
scanner.

If scanimage is unable to identify the
scanner, this message will appear:

#scanimage -L
No scanners were identified. If you were expecting something different,
check that the scanner is plugged in, turned on and detected by the
sane-find-scanner tool (if appropriate). Please read the documentation
which came with this software (README, FAQ, manpages).

If this happens, edit the backend configuration file in
/usr/local/etc/sane.d/ and define the
scanner device used. For example, if the undetected scanner
model is an EPSON
PerfectionÂ®Â 1650 and it uses the
epson2 backend, edit
/usr/local/etc/sane.d/epson2.conf. When
editing, add a line specifying the interface and the device
node used. In this case, add the following line:

usb /dev/ugen0.2

Save the edits and verify that the scanner is identified
with the right backend name and the device node:

Once scanimage -L sees the scanner, the
configuration is complete and the scanner is now ready to
use.

While scanimage can be used to perform
an image acquisition from the command line, it is often
preferable to use a graphical interface to perform image
scanning. The graphics/sane-frontends
package or port installs a simple but efficient graphical
interface, xscanimage.

Alternately, xsane, which is
installed with the graphics/xsane package
or port, is another popular graphical scanning frontend. It
offers advanced features such as various scanning modes, color
correction, and batch scans. Both of these applications are
usable as a GIMP plugin.

7.7.3.Â Scanner Permissions

In order to have access to the scanner, a user needs read
and write permissions to the device node used by the scanner.
In the previous example, the USB scanner
uses the device node /dev/ugen0.2 which
is really a symlink to the real device node
/dev/usb/0.2.0. The symlink and the
device node are owned, respectively, by the wheel and operator groups. While
adding the user to these groups will allow access to the
scanner, it is considered insecure to add a user to
wheel. A better
solution is to create a group and make the scanner device
accessible to members of this group.

This example creates a group called usb:

#pw groupadd usb

Then, make the /dev/ugen0.2 symlink
and the /dev/usb/0.2.0 device node
accessible to the usb group with write
permissions of 0660 or
0664 by adding the following lines to
/etc/devfs.rules: