Publish SANE scanners to MacOS, Android, and Windows via Apple AirScan.
Publish SANE scanners to MacOS, Android, and Windows via Apple AirScan.
AirSane is a SANE frontend, and a scanner server that supports Apple's AirScan protocol. Scanners are detected automatically, and published through mDNS. Acquired images may be transferred in JPEG, PNG, and PDF/raster format.
AirSane's intended purpose is to be used with AirScan/eSCL clients such as Apple's Image Capture, sane-airscan on Linux, and the eSCL client built into Windows 10 and 11.
In addition to the AirScan/eSCL server functionality, a simple web interface is provided.
Images are encoded on-the-fly during acquisition, keeping memory/storage demands low. Thus, AirSane will run fine on a Raspberry Pi or similar device.
Authentication and secure communication are supported in conjunction with a proxy server such as nginx (see the https readme file).
If you are looking for a powerful SANE web frontend, AirSane may not be for you. You may be interested in scanservjs instead.
AirSane implements the Mopria eSCL protocol as published here.
Regarding the mDNS announcement, and the basic working of the eSCL protocol, David Poole's blog was very helpful.
Open http://machine-name:8090/ in a web browser, and follow a scanner
link from the main page.
When opening 'Image Capture', 'Preview', or other applications using the ImageKit framework, scanners exported by AirSane should be immediately available.
In the 'Printers and Scanners' control panel, exported scanners will be listed with a type of 'Bonjour Scanner'.
A macOS compatible scanner plugin for the "GIMP" image editing software is provided here.
If you define a custom icon for your scanner (see below), note that you will have to use the scanner through 'Image Capture' once before it will be shown with this icon in 'Printers and Scanners'. This seems to be a bug in macOS at least up to Catalina.
Install the sane-airscan backend with
sudo apt-get install sane-airscanor whatever the packet manager of your distribution requires to install it.
Using sudo nano /etc/sane.d/dll.conf, add a line "airscan", and prepend a # character
before the "escl" entry if present. (There are two airscan backends, called
"escl" and "airscan", but only "airscan" is compatible with AirSane.)
When done, scanimage -L should list your AirSane devices, and SANE clients such
as XSane or simple-scan should be able to scan from them.
eSCL support in Windows has been introduced in Windows 11 first, but is now available in Windows 10 as well:
Go to "Settings"->"Bluetooth & devices"->"Printers and Scanners." There, click "Add Device". AirSane devices will appear as devices to add, click "Add". Wait until the device appears in the list of devices below, click the device, and choose "Install app" or "Open scanner" in order to install the Microsoft scanner app, or open it if has been installed before. Note that Windows does not allow more than 4 AirSane scanners in total.
As of version 1.4.10, the Mopria Scan App will detect all AirSane scanners and display them with name and icon. After choosing scan options, you will be able to scan to your android device.
Build files and instructions for OpenWRT are published here:
AirSane may be run on a macOS installation in order to serve locally attached scanners to eSCL clients such as Apple Image Capture. For instructions, see the macOS README file.
sudo apt-get install libsane-dev libjpeg-dev libpng-dev
sudo apt-get install libavahi-client-dev libusb-1.*-dev
sudo apt-get install git cmake g++
git clone https://github.com/SimulPiscator/AirSane.git
mkdir AirSane-build && cd AirSane-build
cmake ../AirSane
makeThe provided systemd service file assumes that user and group 'saned' exist and have permission to access scanners. Installing the sane-utils package is a convenient way to set up a user 'saned' with proper permissions:
sudo apt-get install sane-utilsMake sure that sudo scanimage -L lists all scanners attached to your machine.
Listing scanners as user 'saned' should show all scanners as well:
sudo -u saned scanimage -LIf all scanners are listed for 'root' but none for 'saned,' you might have hit
a bug in libsane.
As a workaround, create a file /etc/udev/rules.d/65-libsane.rules with this content:
ENV{libsane_matched}=="yes", RUN+="/usr/bin/setfacl -m g:scanner:rw $env{DEVNAME}"Double-check the location of the setfacl binary using which setfacl, adapt the line if necessary.
Unplug and re-plug all scanners. sudo -u saned scanimage -L should now list all
of them.
To install AirSane:
sudo apt-get install avahi-daemon
make && sudo make install
sudo systemctl enable airsaned
sudo systemctl start airsaned
sudo systemctl status airsanedDisable saned if you are not using it:
sudo systemctl disable sanedDisable unused scanner backends to speed up device search:
sudo nano /etc/sane.d/dll.confThe server's listening port, and other configuration details, may be changed by editing '/etc/default/airsane'. For options, and their meanings, run
airsaned --helpBy default, the server listens on all local addresses, and on port 8090.
To verify http access, open http://localhost:8090/ in a web browser.
From there, follow a link to a scanner page, and click the 'update preview'
button for a preview scan.
/etc/default/airsaneThe options in /etc/default/airsane correspond to command line options of the airsaned program.
The options, and their defaults, are:
listen on named interface only
listening port
listen on named unix socket
HTTP access log file
repeat scanner search on hotplug event
how long a hotplug reload is delayed (seconds)
announce scanners via mDNS
announce secure connection
optional base URL, overrides listen-port and announce-secure options; if the URL's hostname part is %h or %H, it is replaced with the result of avahi_client_get_host_name(), or avahi_client_get_host_name_fqdn(), respectively; if the URL's port part is %p, it is replaced with the value of LISTEN_PORT
enable web interface
allow server reset from web interface
disclose version information in web interface
prepend a random uuid to scanner paths
use /eSCL as path for first scanner
ignore SANE network scanners
location of device options file
location of device ignore list
location of access file
options.conf fileIn addition to the options that may be configured through /etc/default/airsane, it is possible to configure
options to be used when scanning from a certain device.
To specify such options, create a file /etc/airsane/options.conf, readable by user saned.
This file may contain the following kinds of lines:
device, followed with a regular expression,device lines,device sections will be applied.To display the SANE options supported by a device, use sudo -u saned scanimage -L to get its SANE name, and
then sudo -u saned scanimage -d -A to get a list of options.
In options.conf, SANE options must be given without leading minus signs, and with white space between the
option's name and its value. White space is removed from the beginnning and the end of the value.
A gamma value that is applied to grayscale image data before transmission. The gamma value is given as a floating-point value.
A gamma value that is applied to color image data before transmission, using identical gamma values for all components.
A value of yes or no. If set to yes, AirSane will always request color data from the SANE backend, even if the user
requests a grayscale scan. In this case, grayscale values will be computed from RGB component data after gamma correction,
using weights as suited for sRGB data:Y = 0.2126 * R + 0.7152 * G + 0.0722 * B
This is useful for backends that do not allow true grayscale scanning or incorrectly return a single color component even if
true gray is requested (observed with the SANE genesys backend).
Name of a png file that should be used as the scanner's icon. This may be an absolute path, or a relative path. If relative (e.g., just a file name without a path), it is relative to the location of the options file.
The image should have a size of 512x512, 256x256 or 128x128 pixels and an alpha channel for transparency. If pixel dimensions are not powers of two, the image will not be accepted by macOS.
A string that appears in the note field of the mDNS announcement. This should be an indication where the scanner is located,
such as "Living Room" or "Office." If no location is given in the options file, this defaults to the host name of the machine
that runs airsaned.
# Example options.conf file for airsane
# Set SANE brightness to 10 for all scanners
brightness 10
# Set a default icon for all scanners
icon Gnome-scanner.png
# Compensate for OS-side gamma correction with gamma = 1.8 = 1/0.555555
gray-gamma 0.555555
color-gamma 0.555555
# Set options for all scanners using the genesys backend
device genesys:.*
synthesize-gray yes
# Set icon and calibration file option for a scanner "Canon LiDE 60"
device Canon LiDE 60
icon CanonLiDE60.png
location Living Room
calibration-file /home/simul/some path with spaces/canon-lide-60.calWhen receiving scan data from an AirScan scanner, macOS seems to ignore all color space related information from the
transmitted image files, and interprets color and gray levels according to standard scanner color profiles.
Using ColorSync Utility, one can see that these color profiles are called Scanner RGB Profile.icc and
Scanner Gray Profile.icc, located at /System/Library/Frameworks/ICADevices.framework/Resources.
Unfortunately, it is not possible to permanently assign a different color profile to an AirScan scanner using
ColorSync Utility: the specified color profile is not used, and the profile setting is reverted to the original standard profile.
The SANE standard does not prescribe a certain gamma of backend output.
The macOS standar
No open issues yet, or sync has not completed.