SANE stands for "Scanner Access Now Easy" and is an application programming interface (API) that provides standardized access to any raster image scanner hardware (flatbed scanner, hand-held scanner, video- and still-cameras, frame-grabbers, etc.). The SANE API is public domain and its discussion and development is open to everybody. The current source code is written for UNIX (including GNU/Linux) and is available under the GNU General Public License (the SANE API is available to proprietary applications and backends as well, however). More details about the license can be found on our license page. Ports to MacOS X, OS/2 and Microsoft Windows are either already done or in progress.
SANE is a universal scanner interface. The value of such a universal interface is that it allows writing just one driver per image acquisition device rather than one driver for each device and application. So, if you have three applications and four devices, traditionally you'd have had to write 12 different programs. With SANE, this number is reduced to seven: the three applications plus the four drivers. Of course, the savings get even bigger as more and more drivers and/or applications are added.
Twain Sane Interface For Mac
If you're familiar with TWAIN, you may wonder why there is a need for SANE. Simply put, TWAIN does not separate the user-interface from the driver of a device. This, unfortunately, makes it difficult, if not impossible, to provide network transparent access to image acquisition devices (which is useful if you have a LAN full of machines, but scanners connected to only one or two machines; it's obviously also useful for remote-controlled cameras and such). It also means that any particular TWAIN driver is pretty much married to a particular GUI API (be it Win32 or the Mac API). In contrast, SANE cleanly separates device controls from their representation in a user-interface. As a result, SANE has no difficulty supporting command-line driven interfaces or network-transparent scanning. For these reasons, it is unlikely that there will ever be a SANE backend that can talk to a TWAIN driver. The converse is no problem though: it is pretty straight forward to access SANE devices through a TWAIN source. In summary, if TWAIN had been just a little better designed, there would have been no reason for SANE to exist, but things being the way they are, TWAIN simply isn't SANE.
The TWAIN SANE Interface is provided as a binary package and as source code. To use the interface you only have to install the binary package. Before installing the TWAIN SANE Interface package you should install the libusb and the sane-backends binary packages.
There is also a optional SANE Preference Pane package available, which makes it easier to configure the sane-backends drivers. If you don't install this package you can still configure the sane-backends using a text editor in the Terminal.
TWAIN is scanning protocol that was initially used for Microsoft Windows and Apple Macintosh operating systems, and it added Linux/Unix support since version 2.0. The first release was in 1992. It was designed as an interface between image processing software and scanners or digital cameras.
There are other differences between TWAIN and WIA. TWAIN has three transfer modes (native, memory, file) while WIA has only two (memory, file). TWAIN enables device vendors to create a customized user interface for each driver. WIA uses a simplified user interface for all devices, based on a scripting object model. If you only need basic scanning functions, WIA is enough. If you need to use more sophisticated features of a scanner, such as different options for each page when scanning in duplex mode, TWAIN should be your choice.
This separated implementation makes SANE perfectly suitable for a network scanning scenario, where you have all computers connected in a LAN and the scanners connected to only one or two computers as shared scanners. Also, without tying with a specific GUI, as TWAIN does with Win32 or the Mac API, SANE is easier to implement a command-line driven interface. On the other hand, SANE does have some GUIs, like XSane, phpSANE etc., that you can use if needed. Or, you can customize one GUI specifically for one scanner.
To my surprise, there were no decent SANE to TWAIN bridges available. There were two projects (both called WinSANE, no longer online) but neither of those did what I wanted if I could them to work at all. Another solution seemed to be to use a Windows port of XSane but that also wasn't what I wanted: I use Corel PhotoPAINT, and I want to scan from within PhotoPAINT. (When I was more or less finished, I saw that another bridge (twain-to-sane-bridge) had been released. Luckily, again, that did not everything I needed.)
Put the SaneTwain.ds file in the twain_32 folder of your Windows system folder . If you don't have a twain_32 folder, your computer might not have TWAIN installed, see the TWAIN website for details on downloading the TWAIN Data Source Manager. Make sure the SaneTwain.ds file has execution rights set.
It is recommended to start ScanImage first, to set-up the connection to your SANE server. (Note: if you are using Windows NT or 2000, it is probably wise to run it the first time as Administrator). The first time the program is started, a properties window will be shown. This window can be recalled later using the the properties button (). All settings in this window are stored in the sanetwain.ini file, which is stored in your user profile.
It is possible to move the sanetwain.ini to one of the following locations once it has been created: %WINDIR%, %ALLUSERSPROFILE%, or the folder in which the executable is stored. SaneTwain will try these folders in that order, and if no INI file is found in any of these directories, fall back to users profile.
If you want to define a default region to be used by default each time you use SaneTwain, check the "Save regions on exit". Any regions active when the application closes will be saved to the sanetwain.ini file, and restored next time the program starts. This is mutually exclusive with the previous option.
On this tab you can also select the language to use in the user interface. Only languages for which I have translations are shown. If you are willing to create a translation for another language, and are willing to keep those translations up to date if I add new strings, please contact me!
Starting with version 1.29, a special version of SaneTwain is available to be used as WIA driver under Windows XP and Vista. WIA (Windows Image Acquisition) is supposed to be the replacement of TWAIN, and Microsoft provides a standard interface for acquiring images through WIA. For example Windows Fax and Scan provides access to WIA only, and the TWAIN version of SaneTwain cannot be used (at least, not on my Vista PC).
To enable this, using the regular user interface, create scanner settings for each required scanner. This might involve setting hostname for each scanner, letting the software retrieve all available scanners, setting options, and saving them (see the section Saving options below). After each scanner, move the the Host and optionally Port and Username keys to the section for the scanner being configured, and optionally rename the scanner device name (for a more user friendly scanner name; the scanner device name is used as section identifier in the INI file).
It is possible to save option values as defaults to the sanetwain.ini file. Just move the mouse over the input component for the option (e.g. a combobox, or a text entry field), and press Ctrl+S. A message should appear at the bottom of the window with the name of the option and the saved value. The next time SaneTwain is started, the defaults will be read after opening the scanner device. Saving options does not work for "button" options and options which can have multiple values. All options can be saved in one go by pressing Ctrl+A when the main window has focus. Note that this might not work with all combinations of options and values, as setting one option might influence possible values for other options, and all options are restored from sanetwain.ini in the order the backend defined.
It is now also possible to have values in the INI file to be sent to the backend the moment SaneTwain exits. This could for example be used in situations where the backend does not properly turn off the lamp, and an option to turn off the lamp is available. To enable this, save the necessary option value(s) as described in Saving options, and in the INI file prefix the option name(s) with OnExit. (include the dot; use the actual backend option name, not the label shown in the user interface). So, for the given example, have a key OnExit.lamp-switch=0 in the section for your scanner (assuming your backend has an option lamp-switch).
To start, you'll need to install libusb, which allows user level application to interact with USB devices, and the SANE backends. You are then ready to install the TWAIN SANE Interface, and for Mac users, you should also install the SANE Preference Pane. Once you've done this, you can use the Preference Pane to fine your specific model of scanner, and then inspect the configuration file to add support for your specific modem of scanner. To see if SANE can find your scanner, you can issue the "sane-find-scanner" command, or the "scanimage -L" command. If neither of these find your scanner, you may need to restart with the scanner powered on.
As you can see from the screen shot, the TWAIN SANE interface offers many options to control scanning. For this device, the Standard settings let you choose the paper source, the scan mode (color or grayscale) and the horizontal and vertical resolution in dpi. The Geometry settings sets what part of the page you'd like to scan. The Enhancement section can include options like brightness, contrast and emphasis. Depending on your driver and device, you may get more or less options.
I have been using a Mustek 1200 large usb scanner with Photoshop 4 when I upgraded to a OS 10.8 Mac (and PS 6) the scanner now fails to register in Photoshop 6 or in Print/Scan Pref (i had twain installed) any ideas? 2ff7e9595c
Comments