Using Scanners on NetBSD

Setup

To connect a USB scanner do:

  1. Check if it is supported by SANE:

SANE:Supported Devices

  1. Make /dev/ugen0 usable through removal of uscanner from the kernel config by commenting it:

     # cd /usr/src/sys/arch/i386/conf
     # cp GENERIC GENERIC_UGEN
    

    Comment out the uscanner device:

     # vi GENERIC_UGEN
    

    by using '#' so it looks like:

     # USB scanners
     # uscanner* at uhub? port ?
    

    Then, continue to config, make and install the new kernel:

     # config GENERIC_UGEN
     # cd ../compile/GENERIC_UGEN
     # make depend
     # make
     # cp netbsd /netbsd.ugen
     # cp /netbsd /netbsd.old
     # cp netbsd /netbsd
     # shutdown -r now
    
  2. Add the SANE packages to the system:

     # cd /usr/pkgsrc/graphics/sane-backend
     # make install
     # cd ../sane-frontend
     # make install
     # cd ../xsane
     # make install
    
  3. Connect the USB scanner and check if it's recognized:

     # sane-find-scanner
    

    When the scanner is found, check if it is correctly supported and usable:

     # scanimage -L
    

    Some scanners (e.g. the Epson Perfection 2480) need firmware loaded; put the firmware image in some place and add the scanner backend configuration file to point to it.

    Scan an image by using the name of appropriate backend found on the SANE supported devices page (usually printed out by sane-find-scanner), for an example:

     # scanimage -v -B -d name_of_backend:libusb:/dev/usb0:/dev/ugen0 --format pnm > /tmp/image.pnm
    

    or

     # scanimage -v -B -d hp:libusb:/dev/usb0:/dev/ugen0 --format pnm > /tmp/image.pnm
    

    or

     # scanimage -v -B -d gt68xx:libusb:/dev/usb0:/dev/ugen0 --format pnm > /tmp/image.pnm
    

    or use an alternative X frontend:

     # xsane
    

    To find what options are available, do:

     # scanimage --help -d gt68xx:libusb:/dev/usb0:/dev/ugen0
    

User access

To grant another user access to use the scanner, create a 'scanner' group.

# groupadd scanner

Add user to the group scanner:

# usermod -G scanner user_name

Change group for a device:

# chgrp scanner /dev/ugen*

For some drivers, you also need access to the usb bus devices:

# chgrp scanner /dev/usb*

Also check if the permissions are sufficient, otherwise also do:

# chmod g+rw /dev/usb* /dev/ugen*

Additional features

To postprocess the images, the ImageMagick package is very useful. For example, to batch-convert some images to black/white, use:

# mkdir ./bw ; for f in *.jpg ; do convert -colorspace gray "$f" "./bw/$f.jpg" ; done