next up previous contents index
Next: Camera Interface Up: File menu Previous: Custom image format examples   Contents   Index


Scanner

(Unix version only) Acquires an image from a H/P compatible scanner. HP-compatible SCSI scanners are supported directly. Other scanners are supported with external drivers, using a driver configuration file (See below).

Note: In the past, Hewlett-Packard distributed a Scanner Control Language Toolkit which provided documentation on their scanners to developers. Hewlett-Packard no longer provides this information. This makes it difficult to support HP SCSI scanners in Linux, and consequently these devices are no longer recommended.

Setting up a scanner

Here is a brief outline of the procedure for attaching a scanner in Linux on an x86 system. For more details, consult the Linux SCSI-HOWTO. For Sun and SGI systems, these steps should not be necessary. Convex does not seem to support a SCSI interface.

  1. Install a supported SCSI-2 card and H/P scanner. One combination known to work is an Adaptec AHA-1542CF card and H/P 4C scanner.
  2. Throw away the cheap printer-type cable and the SCSI card supplied with the scanner and use a good quality SCSI cable (Centronics-type connector at both ends) and a good SCSI card to connect the scanner.
  3. Recompile your kernel if necessary to add ``generic SCSI'' support and support for the low-level driver for your SCSI card (see the Linux Kernel-HOWTO).
  4. Shut down the system and make sure the scanner and the SCSI card are both properly terminated. Set the SCSI ID of the scanner to some known value less than 7. Power up the scanner before turning the computer back on. The scanner must be connected and powered on before booting the computer in order to be recognized.
  5. The SCSI card should display a message at boot-up indicating its presence. Most Adaptec cards can be configured for IRQ, SCSI ID, etc. at this point by typing Ctrl-A during boot-up. Using the card's DIP switches to turn off the card's BIOS may also help.
  6. At boot-up, if the SCSI card is recognized, you will see a message such as:

    kernel: scsi0 : Adaptec 1542
    kernel: scsi : 1 host.

    If the scanner is hooked up correctly, you will also see a message such as:

    kernel: scsi: type is processor
    kernel: Vendor: HP Model: C2520A Rev: 3503
    kernel: Type: Processor ANSI SCSI revision: 02
    kernel: Detected scsi generic sga at scsi0, channel 0, id 5,
    lun 0
    kernel: scsi : detected total.

  7. If this message does not appear, the most likely cause is that the scanner is not terminated or an incorrect cable was used. Remember the device name (in this case ``sga''). It may be helpful to create a link to this device named ``scanner'' in /dev.
  8. As a last check, `` cat /proc/devices '' should list `` 21 sg '' as one of the character devices. This device will be listed only if the scanner device is detected at boot-up. If it is not listed, it may be necessary to create a device file using MAKEDEV and then change the permissions on the device file. It should look something like this:

    crwxrwxrwx 1 root root 21, 0 Feb 9 17:30 /dev/scanner

    You can also create links or additional /dev files to describe the same device, for example:

    crwxrwxrwx 1 tjnelson users 21, 0 Oct 3 1998 /dev/scanner
    crwxrwxrwx 1 root disk 21, 0 Jan 19 1999 /dev/sg0
    lrwxrwxrwx 1 root root 3 Oct 3 1998 /dev/sga sg0

    The important thing is the 21,0. If you change it in the scan dialog, it is remembered next time imal is started.

Scanning an image

  1. Select ``File...scanner..'' and change the scanner device name, resolution, brightness, contrast, etc. as desired. Click the ``Preview Scan'' button then click OK. The scanner should immediately begin to scan a small, temporary, preview image. (The preview image is scanned at 50 dpi).
  2. When the preview image is finished scanning, the dialog box will appear again. Change the contrast, brightness, resolution, etc. if necessary and click on ``Image scan'' then ``OK''. Although it is possible to enter any number for resolution, some scanners may only accept specific values, such as 50, 75, 100, 150, 300, 600, or 1200 dpi. Entering a resolution inappropriate for a given scanner could result in the parameter being ignored by the scanner.
  3. After you click OK, a message box will appear reminding you to select the scan coordinates for the Image Scan. Using the mouse, select a region in the preview image. During this phase, the mouse is constrained within the preview image to prevent scanning of impossible coordinates. The selected region will be outlined with a ``crawling box'' and, when the mouse button is released, scanned at the selected resolution and placed in a permanent image buffer. Additional regions may be selected and scanned as many times as desired to create more images.

    Note: Occasionally, a crawling box will already be present at this point. It is still necessary to select a region to scan, even if the crawling box appears to be in the correct position.

  4. To scan a new original, click ``Preview'' again to create a new preview image, or click Cancel if finished. The temporary image is automatically erased.

    NOTE: Scanner support has not been tested in the Irix or Solaris versions. Information as to whether this works will be appreciated. The scanner interface is not supported in MS-DOS or ConvexOS.

    WARNING: If imal detects an unsupported type scanner, it displays the message:

    Not an HP scanner
    Continuing may cause a lockup
    Do you want to continue?

    Click ``OK'' to attempt to use the scanner. Do this at your own risk. This will most likely hang the SCSI bus.

Notes:

Scanner configuration for non-HP scanners

In addition to HP scanners, any other scanner can be used provided that a suitable driver is installed. Below is the procedure for installing and configuring scanner drivers, using the umax-cli driver written by Oliver Rauch and Michael K. Johnson as an example. These steps should only be necessary for non-HP scanners, as HP SCSI scanners are supported internally by imal.

WARNING Read the following before creating a scanner driver configuration file. Using an incorrect file could crash imal or even hang the SCSI bus.

  1. Install the scanner driver. (The umax driver is located at

    ftp://tsx-11.mit.edu/pub/linux/ALPHA/scanner).

  2. Ensure that the environment variable $HOME (or $home if you are using csh or tcsh) is defined.
  3. Create the directory in $HOME/.imal if necessary and ensure that you have read/write permission in that directory. (These steps should already be done by the Install script).
  4. Create a file in $HOME/.imal named ``scanners''. This file is a list of configuration files you will create, one filename per line. For example:

    umax
    mustek
    my_other_scanner

  5. Determine the command line options for the scanner driver you just installed by consulting the documentation or man page. Take note of what options set the dpi, top, left, width, height, and bits/pixel, and determine whether it creates a file or sends its output to stdout (i.e., to the screen). Note that the options may be case-sensitive, and may or may not require a space between the option and its value. These options may vary considerably from the example shown below.
  6. Once the command line options are known, test the scanner driver to make sure it is working. The term ``scanner driver'' is used here to mean a command line program that controls the scanner. To be compatible with imal, the driver must have the following characteristics:
    1. It must be an executable command-line program in your path or in some known location.
    2. Its permissions must be such that you and other users can execute it.
    3. It must take its scanning options from the command line.
    4. It must be able to create an image file in some valid image format.
    5. It must either write to stdout, or create a file with a specified filename.

    Use the following procedure to test the scanner driver:

    1. Type a command line appropriate for the scanner driver, e.g., mydriver {options} > testfile .
    2. Check to make sure imal can open the resulting file testfile as a valid image.
    3. If so, it should be possible to create a driver config file that will work.

  7. Using the supplied umax file as an example, create a configuration file (named, in this case, umax) to indicate to imal the command-line options needed by the driver, and its location. Here is a minimal example configuration file with the umax parameters added:
            name  Umax
            driver_path $HOME/scanner/umax/umax-0.5.6/umax-cli
            dpi_command    -R
            left_command   -X
            top_command    -Y
            width_command  -w
            height_command -h
    

    NOTE: Each scanner driver has different command-line options. For example, the ``-R'' command sets the dpi for umax-cli but other scanner drivers may use a completely different command line option.

    The ``name'' can be any name, which will appear in the menu. imal will automatically supply appropriate numerical values for the other options based on the settings you provide interactively in the scanner dialog. Lines with no option or lines starting with a `#' are ignored. Not all options are meaningful for all drivers.

  8. Make sure you have write permission in the directory $HOME/.imal before starting a scan. This is where imal will create its named pipe, ``fifi''.
  9. Test the configuration file by starting imal in diagnostic mode (i.e., imal -diag > outfile ). The outfile will contain a copy of the command line composed by imal . Check this command line to make sure it is correct.

    For example, here is part of the output from imal in diagnose mode when using a Umax scanner:

      ...
      Scanner command:
      $HOME/scanner/umax/umax-0.5.6/umax-cli -R 50 -X 0 -Y 0 -w 2550 
          -h 3300 -b 127 -c 127 -r >/home/tjnelson/.imal/fifi
      Reading image /home/tjnelson/.imal/fifi
      ...
    

  10. Once the configuration file is working properly, copy it to $HOME/.imal (or $home/.imal if you are using csh or tcsh).
  11. If you wish, send me a copy of the config file so it can be included with future versions of imal for the benefit of other users.

The scanner driver will now function as an integral part of imal. The configuration file (shown here with commands for the Umax driver) may also contain other options including:

brightness_command -b
contrast_command -c
bpp_command Set bits/pixel
gray_8_command Scan 8 bits/pixel grayscale
gray_10_command Scan 10 bits/pixel grayscale
gray_12_command Scan 12 bits/pixel grayscale
gray_16_command Scan 16 bits/pixel grayscale
color_24_command Scan 24 bits/pixel color
color_30_command Scan 30 bits/pixel color
color_36_command Scan 36 bits/pixel color
gray_command -g Scan in default grayscale mode
color_command -r Scan in default color mode
preview_command -p
extra_commands Any additional command options entered here will be sent verbatim to the scanner. For example, -s = slow speed, -W = warm up lamp before scanning. If all else fails, this line can be used alone to send a fixed command line to the driver.

Conversion factors may also be added in case scanner driver uses some other units besides pixels at 300 pt/inch. For example, if driver requires all units to be in inches, set each value to 72. If the driver uses 1200 pt/inch instead of 300, set each value to 4. Values do not have to be integers.

height_factor 1
width_factor 1
top_factor 4
left_factor 4

Numbers may need to be added to the contrast and brightness values supplied by imal (which range from 0 to 255) to convert to the range used by the scanner driver. For instance, if the driver uses -127 to +127 instead of 0 to 255, enter -127 here.

contrast_add 0
brightness_add 0


next up previous contents index
Next: Camera Interface Up: File menu Previous: Custom image format examples   Contents   Index
root 2008-10-10