# SANE

From ArchWiki
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Related articles

- SANE/Scanner-specific problems
- Scanner Button Daemon

SANE (Scanner Access Now Easy) provides a library and a command-line tool to use scanners under GNU/Linux.

Check if your scanner supports eSCL or WSD; chances are good if your device is on this Internet Printing Protocoll - IPP list of devices that support eSCL. If your device has eSCL/WSD support, modern "driverless" scanning is recommended.

## Installation

Install the sane-airscan package if the scanner is known to work in driverless mode. If your scanner is using USB connection, make sure to also install the ipp-usb package and start/enable `ipp-usb.service` to allow using IPP protocol over USB connection.

If not, see [1] to check if SANE supports your scanner using a classic driver.

Install the sane package to use old driver-based scanning.

## Verification

Now you can try to see if sane recognizes your scanner.

    $ scanimage -L

If that fails, run the command again as root to check for permission problems. If that fails as well, check that your scanner is plugged into the computer. You also might have to unplug/plug your scanner for `/usr/lib/udev/rules.d/65-sane.rules` to recognize your scanner.

Now you can see if it actually works

    $ scanimage --format=png --output-file test.png --progress

If the scanning fails with the message `scanimage: sane_start: Invalid argument` you may need to specify the device.

    $ scanimage -L

    device `v4l:/dev/video0' is a Noname Video WebCam virtual device
    device `pixma:04A91749_247936' is a CANON Canon PIXMA MG5200 multi-function peripheral

Then you would need to run

    $ scanimage --device "pixma:04A91749_247936" --format=tiff --output-file test.tiff --progress

Sane provides many special backend options for numerous scanner types. To see what these are for your device:

    $ scanimage -A

## Installing a scanner driver

Most scanners should work out of the box. If yours does not, see SANE/Scanner-specific problems for installation instructions.

### Firmware

Note: This section is only needed if you need to upload firmware to your scanner.

Firmwares usually have the `.bin` extension.

Firstly you need to put the firmware someplace safe, it is recommended to put it in a subdirectory of `/usr/share/sane/`.

Then you need to tell sane where the firmware is:

- Find the name of the backend for your scanner from the sane supported devices list.
- Open the file `/etc/sane.d/backend-name.conf`.
- Make sure the firmware entry is uncommented and let the file-path point to where you put the firmware file for your scanner. Be sure that members of the group `scanner` can access the `/etc/sane.d/backend-name.conf` file.

If the backend of your scanner is not part of the sane package (such as `hpaio.conf` which is part of hplip), you need to uncomment the relevant entry in `/etc/sane.d/dll.d` or in `/etc/sane.d/dll.conf`.

### Fujitsu fi series

For some of the Fujitsu fi series document scanners, the pfufsAUR proprietary driver offers advanced functionality over the already mature SANE default driver, such as control of an optional imprinter for stamping scanned documents or requesting accurate status of the consumables from the host.

## Install a frontend

Many frontends exist for SANE, a non-exhaustive list of which can be found on the sane-project website.

- Simple Scan — Simplified GUI that is intended to be easier to use and better integrated into the GNOME desktop than XSane. It was initially written for Ubuntu and is maintained by Robert Ancell of Canonical Ltd. for GNU/Linux.

  https://gitlab.gnome.org/GNOME/simple-scan || simple-scan

- Skanlite — Simple image scanning application that does nothing more than scan and save images, based on the KSane backend.

  https://www.kde.org/applications/graphics/skanlite || skanlite

- XSane — Full-featured GTK-based frontend looking a bit old but providing extended functionalities.

  http://www.xsane.org/ || xsane

Some OCR software are able to scan images using SANE: gImageReader, gscan2pdf, Linux-Intelligent-Ocr-Solution, OCRFeeder, Paperwork.

Note:

- Scanning directly to PDF using XSane in 16bit color depth mode is known to produces corrupted files and a note in `pacman` output warns so. 8bit mode is known to work.

The factual accuracy of this article or section is disputed.

Reason: skanlite does not need to handle mDNS. As long as mDNS hostname resolution is set up correctly and the scanner 's address is specified as `hostname.local`, it should just work. This looks like a hplip limitation/bug. (Discuss in Talk:SANE#)

- Using a frontend does not mean you do not have to apply some tricks. This is especially true with devices configured via mDNS. For example, `skanlite` needs to have additional info specified on the command line in order to detect a network scanner properly as it cannot handle mDNS. Here is an example with an HP Officejet Pro L7590: `skanlite --device "hpaio:/net/Officejet_Pro_L7500?ip=192.168.0.17"`.

## Network scanning

### Network attached scanners

Many modern scanners will immediately work over the network as long as you have sane-airscan installed.

#### Scanning over the network with Canon PIXMA or imageCLASS all-in-one printer/scanners

Find out your printer/scanner's IP address, and add it on a new line to `/etc/sane.d/pixma.conf` in the format `bjnp://10.0.0.20`. For imageCLASS printers you may need to use the format `mfnp://10.0.0.20` instead.

Tip: Instead of an IP address, if mDNS resolution is set up, you can use the mDNS `.local` address. E.g. `bjnp://MyPixmaPrinter.local`.

Sane should now find your device. For more details refer to sane-pixma(5).

Alternatively, scangearmp2AUR can be used for some Canon PIXMA all-in-one printer/scanners which are not detected over the network.

See SANE/Scanner-specific problems for additional information.

#### Scanning over the network with EPSON WorkForce printer/scanners

Install imagescan and imagescan-plugin-networkscanAUR.

Edit the config file `/etc/utsushi/utsushi.conf`. Find the `[devices]` section and edit the template for `dev2`. Replace the IP address accordingly. You can find the IP address on your printer screen. For example,

    ...
    dev2.udi    = esci:networkscan://192.168.1.123:1865
    dev2.model  = WF-2860
    dev2.vendor = EPSON
    ...

Meanwhile, comment out `epson2` in `/etc/sane.d/dll.conf` as it conflicts with ImageScan.

Once this is done you can use any SANE frontend to access this scanner.

### Sharing your scanner over a network

You can share your scanner with other hosts on your network who use sane, xsane or xsane-enabled GIMP. To set up the server, first indicate which hosts on your network are allowed access.

Change the `/etc/sane.d/saned.conf` file to your liking, for example:

    # required
    localhost
    # allow local subnet
    192.168.0.0/24

If you use iptables, insert the `nf_conntrack_sane` module to let the firewall track `saned` connections.

Conntrack helper seems to be disabled by default.[2] You can activate it with

    # echo 1 > /proc/sys/net/netfilter/nf_conntrack_helper

To configure this permanently, set the `nf_conntrack_helper=1` option for the `nf_conntrack` module, see Kernel module#Using files in /etc/modprobe.d/.

Now start/enable `saned.socket`. Your scanner is now available over the network. For more information, see saned(8).

Note: saned intentionally refuses to share scanners that use the net: backend (which includes some USB scanners). There is a crude patch to allow this in FS#54786, but note it may cause problems on some networks. Check output of `scanimage -L` on the server to see the scanner url.

### Accessing your scanner from a remote workstation

Note: Some network scanners require a different approach. See SANE/Scanner-specific problems.

You can access your network-enabled scanner from a remote Arch Linux workstation.

First, specify the server's host name or IP address in the `/etc/sane.d/net.conf` file:

    # static IP address
    192.168.0.1
    # or host name
    stratus

Now test your workstation's connection:

    $ scanimage -L

The network scanner should now also show up in any front-end.

### Windows clients

Since the Windows port of SANE seems to be unsupported, outdated and difficult to get, you can try SANEWinDS or SaneTwain (old).

## Troubleshooting

  See also: SANE/Scanner-specific problems

### Invalid argument

If you get an "Invalid argument" error with xsane or another sane front-end, this could be caused by one of the following reasons:

#### Missing firmware file

No firmware file was provided for the used scanner (see #Firmware for details).

#### Wrong firmware file permissions

The permissions for the used firmware file are wrong. Correct them using

    # chown root:scanner /usr/share/sane/SCANNER_MODEL/FIRMWARE_FILE
    # chmod ug+r /usr/share/sane/SCANNER_MODEL/FIRMWARE_FILE

#### Multiple backends claim scanner

It may happen, that multiple backends support (or pretend to support) your scanner, and sane chooses one that does not do after all (the scanner will not be displayed by `scanimage -L` then). This has happened with older Epson scanners and the `epson2` resp. `epson` backends. In this case, the solution is to comment out the unwanted backend in `/etc/sane.d/dll.conf`. In the Epson case, that would be to change

    epson2
    #epson

to

    #epson2
    epson

This article or section is out of date.

Reason: The iscan and iscan-data packages have been dropped from the official repositories [3] without moving to the AUR. However, iscan-for-epson-v500-photoAUR provides iscan and iscan-data (since "iscan[community] is out-of-date and buggy"), so it appears that the AUR PKGBUILDs that depend on iscan and iscan-data (and others) may be able to use iscan-for-epson-v500-photo instead. This still needs to be tested though. (Discuss in Talk:SANE#)

It may also be possible that the independent iscan[broken link: package not found] `epkowa` backend interferes with your `snapscan` backend (epson scanners). You may get this error right after using the `scanimage -L` command. Starting the scanner app (like xsane) twice can also solve the problem. Otherwise check your `/etc/sane.d/epkowa.conf` for wrong configurations or remove the iscan[broken link: package not found] package.

#### Communication via xHCI not working (older scanner models)

Some older scanner models do not work when connected via an USB3 port. If you experience this issue, try setting the `SANE_USB_WORKAROUND=1` environment variable before starting your frontend.[4][5]

If that does not work, try one of the following workarounds:

- Use an USB2 port instead of an USB3 port, if available.
- Disable xHCI via BIOS/EFI. eHCI will consequently be used and communication with the scanner will work. On the downside, USB3 speed can not be reached on any port.
- On (some) intel chipsets the `setpci` command can be used to route specific usb ports to either the xHCI or the eHCI controller. See here and here (scroll down to where it says "setpci") for further information. With this it is possible to toggle single USB ports with a simple shell script.
- Connect the scanner over the network instead if it is supported.

#### Firewall

When network scanning scanner hangs, then invalid argument error occured.

saned uses data port range, so you must enable connections to 6566/tcp and data_portrange from /etc/sane.d/saned.conf or use conntrack firewall module for sane to enable data ports as described above.

### Slow startup

If you encounter slow startup issue (e.g. `xsane` or `scanimage -L` take a lot to find scanner) it may be that more than one driver supporting it is available.

Have a look at `/etc/sane.d/dll.conf` and try commenting out one (e.g. you may have `epson`, `epson2` and `epkowa` enabled at the same time, try leaving only `epson` or `epkowa` uncommented).

You can also try to comment out `net` driver, if there are no network scanners.

Your webcam might also be listed as scanning device and slow down detection at startup. To blacklist webcam, try commenting out all the lines in `/etc/sane.d/v4l.conf`.

### Device busy

The factual accuracy of this article or section is disputed.

Reason: The user should not need to be in the scanner group (see Users and groups#Pre-systemd groups) (Discuss in Talk:SANE#)

If your USB device is listed with `scanimage -L` but launching the test `scanimage pixma:04A9173E_11DAD1 --format=tiff --output-file test.tiff` always return the 'Device busy' error, you might try to add your username to the scanner group `usermod -a -G scanner yourusername` then blacklist the `usblp` kernel module by writing `blacklist usblp` in `/etc/modprobe.d/no-usblp.conf` (it prevents `usblp` from loading to support scanning, not needed by xsane and related tools, might also conflict with CUPS). Reboot to finish. [6]

In addition to this, some Cannon printers return "device busy" if the scan mode is set to "Computer". Setting this to the "Remote Scanner" mode should fix the issue.[7]

### Permission problem

With systemd, the `scanner` and `lp` groups are deprecated. No need to add your user to those groups. See Users and groups#Pre-systemd groups for detail.

You can also try to change permissions of usb device but this is not recommended, a better solution is to fix the Udev rules so that your scanner is recognized.

First check connected usb devices with `lsusb`:

    Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
    Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
    Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
    Bus 003 Device 003: ID 04d9:1603 Holtek Semiconductor, Inc.
    Bus 003 Device 002: ID 04fc:0538 Sunplus Technology Co., Ltd
    Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
    Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
    Bus 001 Device 006: ID 03f0:2504 Hewlett-Packard
    Bus 001 Device 002: ID 046d:0802 Logitech, Inc. Webcam C200
    Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

In our example we see the scanner: `Bus 001 Device 006: ID 03f0:2504 Hewlett-Packard`. Here `03f0` is the vendorID and `2504` is the productID.

Now open `/usr/lib/udev/rules.d/49-sane.rules` and see if there is there is a line with the vendorID and productID of your scanner. If there is not any, create the new file `/etc/udev/rules.d/49-sane-missing-scanner.rules`, with the following contents:

    ATTRS{idVendor}=="vendorID", ATTRS{idProduct}=="productID", MODE="0664", GROUP="lp", ENV{libsane_matched}="yes"

Save the file, plug out and back in your scanner and the file permissions should be now correct.

The factual accuracy of this article or section is disputed.

Reason: The scanner needs to be added to the right backend file, `hp4200.conf` will not work for any scanner. (Discuss in Talk:SANE#)

Another tip, is that you can add your device (scanner) in backend file:

Add `usb 0x03f0 0x2504` to `/etc/sane.d/hp4200.conf` so it looks like this:

    #
    # Configuration file for the hp4200 backend
    #
    #
    # HP4200
    #usb 0x03f0 0x0105
    usb 0x03f0 0x2504

#### Parallel port scanners

All devices attached to a parallel port are assumed to be printers, and are given a `lp` group. Either create a udev rule to mark the relevant parallel port as `libsane_matched`, or add your user to the `lp` user group. CUPS also uses the `lp` group for read-only access to configuration files, so there are potential security implications to adding users to the `lp` group - see CUPS#Connection interfaces for more information.

Category:

- Digital imaging

Hidden categories:

- Pages or sections flagged with Template:Accuracy
- Pages or sections flagged with Template:Out of date
- Pages with broken package links