1. Home
  2. Tutorials
  3. Scanners
Yolinux.com Tutorial

Scanners and Linux

Using optical scanners with Linux.

Imaging profesionals will want to perform a monitor color corection and calibration prior to using and tuning a scanner.
See our Linux monitor calibration tutorial.


Free Information Technology Magazines and Document Downloads
TradePub link image

SANE and XSANE Scanner Software:

To utilize a scanner under Linux one must install the "SANE" software package. It is also wise to employ a front-end application for scanning such as Xsane. Linux uses a software interface to scanning devices known as SANE. PC's often use TWAIN. These software packages run as interfaces between the application and the scanner. SANE is like TWAIN except that it allows network access to the scanner through the saned (Networked scanner daemon). TWAIN is not network enabled and merely talks to local applications. (It is not necessary to run the saned for local applications.)

The current SANE release talks to SCSI scanners. Most non-USB scanners are SCSI scanners. Even if the scanner comes with it's own card, that card is likely a simple SCSI card with a limited feature set which can provide enough features to talk to the scanner.

See this link to see what scanners are supported by SANE: http://www.mostang.com/sane/sane-backends.html

SCSI Tutorial:

SCSI devices under Linux are often named to suite the device. For example the first SCSI tape drive is /dev/st0. The first SCSI CD-ROM is /dev/scd0. When using scanners, one uses the "raw" device name.

SCSI ID Number Linux Device
0 /dev/sga
1 /dev/sgb
2 /dev/sgc
3 /dev/sgd
4 /dev/sge
5 /dev/sgf
6 /dev/sgg
7 /dev/sgh

The SCSI device number 7 is usually reserved for the SCSI card itself.
To list scsi devices on Linux system: cat /proc/scsi/scsi

Set up a new logical device: As root: ln -s /dev/sgX /dev/scanner where X refers to your raw SCSI device. One may also want to change privileges for the device: chmod ugo+r /dev/sgX. (You may want to set up a group and privileges for the group if this is on a server.)

Downloads / Configuration:

Configuration files: The defaults from the Red Hat rpm do not require any changes. Here are my samples for my HP Scanjet 5p (or any HP scanner)

File: /etc/sane.d/dll.conf

#net     - If this is uncommented, then it enables network access
hp
pnm      - Used with virtual devices, i.e. GIMP. You may comment this out
         
File: /etc/sane.d/hp.conf (default will work) - There are many other files to provide support for other manufacturers.
scsi HP C5110A
/dev/scanner
      

Test to see if the device is recognized: scanimage -L

device `pnm:0' is a Noname PNM file reader virtual device
device `pnm:1' is a Noname PNM file reader virtual device
device `hp:/dev/sgc' is a Hewlett-Packard C5110A flatbed scanner
device `hp:/dev/scanner' is a Hewlett-Packard C5110A flatbed scanner
      

Pitfalls:

  • If you don't get this, reboot the system so that the system picks up and accounts for the links and device security changes.
  • Make the scanner the first with that name. For example I had an HP CR-ROM that was scsi device 4 and the HP scanner was scsi device 6. Scanimage would probe and return that the first HP device was the CD-ROM and would assume that it was the scanner. I had to change the scanner to device 2 so that it would be the first HP device scanned.

Man pages: saned, scanimage, xscanimage, sane-scsi, sane-pnm, sane-dll
Man pages on devices: sane-apple, sane-epson, sane-hp, sane-microtek, etc
See "rpm -ql sane" to see all files and man pages in package.

Look at: man sane-scsi This tells of how to recompile the kernel for a larger scsi buffer for more speed if you want to optimize your system. Red Hat should do this by default!!!!!

Using the scanner:

Yes the sane rpm package comes with xscanimage but Xsane takes alot of the pitfalls out of the operation. (but not all) Thus I recommend using Xsane as your scanning application.

  • Start by issuing the command (or create a launch icon): /usr/bin/xsane
  • Choose device /dev/scanner and select "Ok".
  • Select options:
    • "Scan" and "Color". Set the image extension (i.e. jpeg) and output file name.
    • Set brightness (i.e. 50) and change output extension to jpeg (example)
    • Set resolution for HP ScanJet 5p for 100 to get full size on a 17" 1280x1024 monitor
  • Choose "View" + "show preview" then "Acquire Preview". See pitfall below.
  • Adjust size of preview "elastic" box to fit image.
  • Back on main dialog box select "Start"

Pitfalls: Note that the order of operation is important. You MUST use the preview window and do an "Aquire Preview" first before each scan. If you select the "Start" button to scan immediately, you may get nothing. To set the size in the preview window, adjust the "elastic box" or "marching ants". It is already there. The "elastic" box is already there. (you just can't see it the first time) Select the corner of the "elastic" box in the corner of the preview window. You can't see it but it is there. Just left-click at the corner of the preview window and drag. Adjust to the size of your image. Other orders of operation are possible but they may result in no real image.

Also note that if you choose the file number incrementer, that this feature maxes out at 9.

Tips: XSane 0.82

  • The icons at the bottom of the main XSane options panel will reset all the defaults. I take all the defaults and then double "Gamma" to 2.0 (Black gamma slider)
  • Scan resolution defaults to 100. I set it to 72 which matches most monitor resolutions.

More Information:

Commercial scanning products:

Scanning Tips:

Sane Manual pages:

Links:

   
Bookmark and Share

Advertisements