April 22, 2008

Give your scanner a new fresh SANE installation ...

Many Canon Pixma models are supported directly by the Sane Library (through the pixma backend), and the use of an older specific driver is not necessary anymore. Support is either natively brought by the Linux distribution you're running, latest models or bug fixes become available by using the git version

So it became necessary to rationalize all the older articles posted on that blog, in order to guide users to the sole and correct solution to install the pixma backend on their system. Old articles have been retailored, this main tutorial has now all the necessary stuff to get your Pixma scanner ready to use with Sane.

This little guide will explain you how to get the latest Sane git version to be installed on your system. As always, the Sane git version contains the latest release of the Sane pixma backend.
Note that the procedure here can be used also for installing the version 1.0.20 of the Sane library.

All recent PIXMA and ImageClass models are supported, see the man pages or sane-project.org doc pages for more information.
The following models have at least been tested or reported to work fine with Sane.
  • PIXMA MP210, MP220, MP240, MP250, MP260, MP270
  • PIXMA MP450, MP460, MP470, MP480, MP490
  • PIXMA MP500, MP510, MP520, MP530, MP540, MP560
  • PIXMA MP600, MP600R, MP610, MP620, MP630, MP640, MP710
  • PIXMA MP800, MP800R, MP810, MP830, MP960, MP970, MP980, MP990
  • PIXMA MX300, MX310, MX330, MX700, MX850, MX860, MX7600
  • MultiPASS MP700, MP730, PIXMA MP750 (no grayscale)
  • ImageCLASS MF3110, MF4010, MF4018, MF4120, MF4122, MF4140
  • ImageCLASS MF4150, MF4270, MF4370dn, MF4380dn
  • ImageCLASS MF4660, MF4690, MF5770, D480
  • I-SENSYS MF4320d, MF4330d

All models are now supported through USB or network BJNP (Canon's proprietary) protocol, Wired Ethernet or Wifi.

As compile Sane can be sometimes tricky, I'll try to give you the way to avoid pitfalls and have it working at the end, without too much efforts.

Hope it helps !! Let's go.
  • Download latest Sane git package

    2 methods to get the latest Sane git package are possible.

    • HTTP access method

      The HTTP access method should be used only if you are restricted by a firewall that won't let you use the git protocol. HTTP is slower and requires more bandwidth than any other access methods.

      You can download an http snapshot at the address hereafter, where Sane git is hosted:


      Download the latest (upper, named MASTER) tar.gz snapshot image

      Do a quick check after download, that the directory contained in the archive is at a current date.
      Then, untar the package into a directory.

    • Or use git to download it, as developers do ...

      This is actually better than the previous method, as you can later easily update (using git again) the content of the downloaded files, simply issuing a git pull command.
      You patch just the modified files, and you will recompile only what has changed, not the whole thing.

      So first, you must install the git application on your system, it should be available already packaged in your distribution repositories, the name should be something like: git-core or git-scm

      Then, in a terminal, enter the following command:

      $ git clone git://git.debian.org/sane/sane-backends.git

      Files download will begin. You’ll get in your current directory, a new directory named sane-backends. This is the main directory were all the Sane source files are located.

      Updating to the latest source files from the repository

      If you want later to update your git directory with the latest version available from the public Sane git repository, in order to build the latest Sane code, you just need to enter the following command, from the sane-backends directory:

      $ git pull

      This will download the latest changes to the files in your directory sane-backends.

      Then, to build Sane, you can apply the following procedure from the "make", then "make install" statements as indicated here below. Only changed files will be recompiled.
  • Build Sane

    Enter the directory sane-backends created after downloading Sane git.

    The procedure is then “almost” classical, with a few points to take into account instead of running a trivial ./configure, make, make install.

    According to your Linux distribution, you need to run the ./configure command with a set of parameters.

    As it is not possible to cover here all existing distributions, details are given for Ubuntu and Mandriva, as samples.

    For these 2 distributions:

    • Check first that the development libusb library is present and installed.

      On Mandriva, the rpm is called something like:


      on Ubuntu, it is called: libusb-dev.

      Install the package, if not already installed.

      Be warned that if not installed, compilation will success, but the backend will not work, and no error message will be prompted!

    • On both distributions, run the ./configure command like this:

      $ ./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var

      This will choose /usr/lib/sane as SANE lib directory, /etc/sane.d as SANE config files dir, and /var/lock/sane as state directory: The ones that are used by Mandriva and Ubuntu.

      Check in the logs coming in the terminal window, at the end of the configure, that it will compile with usb support.

    • Then compile as usual

      $ make

      This will take ... a significative amount of time ... Can have a cup of coffee.

    • Install on Ubuntu

      $ sudo make install

    • Or install on Mandriva

      $ su
      # make install
  • Set non-root users permissions

    Now, permissions for non root users to access the scanners need to be set up, as not achieved by the “make install” statement.

    These permission settings depend also on the Linux distribution: whether it uses hotplug, udev, …

    Ubuntu Hardy and later (Intrepid, ...)
    This tweak is not necessary as hardware detection is performed by HAL and not udev, the scanner should be available for non root users, as long as permissions are set to enable scanning from menu: System/Administration/Users and Groups (need a logout/login for changes to be taken into account).
    However, if you experience permissions problems for non root users (ressource not available) on these latest Ubuntu releases, you should try Lee's suggestion, for tweaking the

    Ubuntu Jaunty
    Try Darryl's tweak on Jaunty 9.04 to set up persistent-to-upgrades udev rules.

    Ubuntu (releases before Hardy Heron 8.04) and Mandriva both use udev to detect USB devices.
    SANE compilation produces a udev rules file, covering all scanners handled.
    It is named: sane-backends/tools/udev/libsane.rules
    You'll need to install it, by simply replacing the current installed file (coming from the SANE package installed by your Linux distribution), with this new one.
    • Locate first this file
      in the /etc/udev/rules.d directory, it should be called XX-libsane.rules

    • Backup this file somewhere

    • Copy over it, the SANE GIT generated libsane.rules
      Keep the same name as the original one.
      This should give you the following statements, for instance, on Ubuntu:

      $ cp /etc/udev/rules.d/70-libsane.rules ~/
      $ sudo cp tools/udev/libsane.rules /etc/udev/rules.d/70-libsane.rules

    • Have udev take into account the new rules
      Simply reboot, or unplug/replug your scanner USB cable.

  • Test Sane installation

    Now, check that the new Sane git is correctly installed.

    Current Sane git sane-backends version is 1.0.21, check it:

    $ scanimage -V
    scanimage (sane-backends) 1.0.21cvs; backend version 1.0.21

    At that point, you should be able to run some scans with scanimage, and if OK, with Xsane :

    $ scanimage -L
    device `pixma:04A91725_10484D' is a CANON Canon PIXMA MP610 multi-function peripheral

    Next statement will perform a short test of the scanner, you may hear it start scanning and promptly stop.

    $ scanimage –T
    scanimage: scanning image of size 640x877 pixels at 24 bits/pixel
    scanimage: acquiring RGB frame, 8 bits/sample
    scanimage: reading one scanline, 1920 bytes... PASS
    scanimage: reading one byte... PASS
    scanimage: stepped read, 2 bytes... PASS
    scanimage: stepped read, 4 bytes... PASS
    scanimage: stepped read, 8 bytes... PASS
    scanimage: stepped read, 16 bytes... PASS
    scanimage: stepped read, 32 bytes... PASS
    scanimage: stepped read, 64 bytes... PASS
    scanimage: stepped read, 128 bytes... PASS
    scanimage: stepped read, 256 bytes... PASS
    scanimage: stepped read, 512 bytes... PASS
    scanimage: stepped read, 1024 bytes... PASS
    scanimage: stepped read, 2048 bytes... PASS
    scanimage: stepped read, 2047 bytes... PASS
    scanimage: stepped read, 1023 bytes... PASS
    scanimage: stepped read, 511 bytes... PASS
    scanimage: stepped read, 255 bytes... PASS
    scanimage: stepped read, 127 bytes... PASS
    scanimage: stepped read, 63 bytes... PASS
    scanimage: stepped read, 31 bytes... PASS
    scanimage: stepped read, 15 bytes... PASS
    scanimage: stepped read, 7 bytes... PASS
    scanimage: stepped read, 3 bytes... PASS

    And the final result:

    $ xsane
Hope you'll succeed to that point !

In Xsane, you may need to adjust the colors precisely (white, black, gray), using the 3 pipette tool in the preview window.
Read Xsane documentation on how to do that. This is very easy to do, and you'll get after that beautiful scans.

To finish, here are some samples obtained with an MP610, scanning at 600 dpi, and an extra view of a small detail on a stamp, scanned at 4800 dpi.

Comments are welcome, feel free to report anything missing or incorrect ...