<!doctype linuxdoc system>
<article>
<title> SANE-Tutorial-JP
<author> 著者： David Mosberger
                &lt;<htmlurl url="mailto:David.Mosberger@acm.org"
                                   name="David.Mosberger@acm.org">&gt;
<trans> 翻訳： 川岸 良治 &lt; <htmlurl url="mailto:kawagisi@yk.rim.or.jp"
                                             name="kawagisi@yk.rim.or.jp"> &gt;
<tdate> 第1版 1999年7月13日作成
<abstract> この文書は、スキャナ用 API の規格である SANE の仕組み、パッケージ
           の使い方、プログラミングの概要等について解説したものです。
</abstract>
<p>
<verb>
The SANE Scanner Interface

         David Mosberger
         David.Mosberger@acm.org
</verb>
 <!--
    This article originally appeared in Linux Journal Issue 47, March 1998
-->
    この記事は Linux Journal Issue 47, March 1998 に発表したものです。

<!--
                                       Abstract
-->
                                       概要

<!--
     SANE stands for ``Scanner Access Now Easy''. It is a universal interface
    that enables you to acquire images from any device that produces raster
    images, including flatbed scanners, video and still cameras and frame
    grabbers. The intent of SANE is to make it possible to write
    image-processing applications without having to worry about peculiarities
    of individual devices. Looking at it from the other side, SANE makes it 
    possible to write a device driver once and only once. That same device 
    driver can then be used by any SANE-compliant application. 
-->
<quote>
    SANE は `Scanner Access Now Easy' の略語です。これは、フラットベッドス
    キャナ、ビデオ、スチルカメラ、フレームグラバ(画面キャプチャ)のようなラ
    スター画像を作るデバイスから画像を取り出すことができる汎用のインタフェ
    ースです。SANE の意義は、個々のデバイスの特性を気にせずに画像処理アプリ
    ケーションが書けるようになるということです。これを別の視点から見ると、
    SANE に準拠したデバイスドライバをたった一度書くだけでいいということです。
    同じデバイスドライバをSANE に準拠した別のアプリケーションからも使えるよ
    うになるのです。
</quote>
<!--
1 Introduction
2 Using SANE
3 What Else Comes with SANE?
4 How Does It Work?
5 Programming With SANE
6 SANE and Commercial Applications/Drivers
7 Future Plans
Acknowledgments
===============
目次
===============
1 はじめに
2 SANE を使う
3 SANE は、その他に何があるのか
4 どのように動作するか
5 SANE のプログラミング
6 SANE と商用のアプリケーション／ドライバ
7 将来の計画
謝辞
-->

<!--
1 Introduction
-->
<sect> はじめに
<p>
<quote>
<!--
Have you ever wanted to scan an image under Linux? If so, you probably know
the feeling of being faced by a bewildering number of scanner-driver packages.
At the time of this writing, there exist at least fourteen different scanner 
packages for Linux. While each individual package is usually of high quality,
it is often difficult to determine which package should be used for which 
scanner. Furthermore, some packages come with a command-line interface, 
others include tcl/tk based graphical front ends, still others come with 
full-featured, graphical front ends. While variety is said to make life sweet,
in this case it's more likely to cause a sizeable headache. 
-->
Linux で画像をスキャンしたいと思ったことはありませんか？ もしそうなら、たぶん
スキャナドライバパッケージの多さに当惑するかもしれません。
これを書いている時点で、少なくとも 14 の Linux 用スキャナドライバパッケージが
存在します。個々のパッケージは高品質ではあるものの、どのドライバパッケージを
どのスキャナに使えばよいのか分からないことがよくあります。
おまけに、あるパッケージはコマンドライン・インタフェース、別のは tcl/tk ベー
スのグラフィカル・フロントエンドがある、さらに完全武装のグラフィカル・フロン
トエンドを持ったものもあるという具合です。バラエティは生活を豊かにするとは
言うものの、この場合はかなり大きな頭痛の種です。
<p>
<!--
SANE was created to provide a solution to this dilemma. The basic idea is 
simple: if there were a general and well-defined application programming 
interface (API), it would be easy to write applications independently from 
scanner drivers. Thus, the author of a new scanner driver would not have to 
worry about writing an application for the driver. There are benefits for the
application programmer as well; since SANE is universal, an application can be
written independently of the devices that it will eventually control. 
-->
SANE はこのジレンマを解決するために作られました。基本的なアイデアは単純です。
つまり、汎用的でよく出来た API(Application Programming Interface) があれば、
スキャナドライバから独立したアプリケーションを書くのは容易です。
従って、新しいスキャナドライバの作者は、ドライバ用のアプリケーションを書く
ことを心配しなくてよいのです。さらにアプリケーション・プログラマにとっても
SANE は汎用的なので、いずれは制御されるであろうデバイス
と独立してアプリケーションを書くことが出来るという利点があるのです。
<p>
<!--
Suppose we wanted five applications to support ten different devices. With 
the old approach, 5*10=50 programs would have to be written. With SANE, only 
5+10=15 programs have to be written. SANE has advantages for the user too. 
It gives the user the liberty to choose whichever application he likes best, 
and that one application can be used to control all image-acquisition devices 
the user can access. Thus, SANE makes it possible to present the same 
consistent interface independent of the particular device that is in use. 
-->
10 の異なるデバイスをサポートするために、5つのアプリケーションが欲しいと
します。古いアプローチでは、5×10=50 で 50 ものプログラムを書かなければ
なりません。SANE では 5+10=15 で 15 のプログラムを書くだけでよいのです。
SANE はユーザにもメリットがあります。ユーザは自分が最も気に入ったアプリ
ケーションを選択する自由が得られ、それをユーザがアクセス可能な全ての画像取込み
デバイスを制御するために使用できます。つまり SANE は、使用中の特定のデバ
イスに一貫したインタフェース独立性を与えてくれるのです。
<p>
<!--
Of course, SANE is not the first attempt to create such a universal interface.
You may have heard of TWAIN, PINT or the Linux hand-scanner interface. 
The problem is that these older interfaces prove to be lacking in one way or 
another. For example, PINT is really a somewhat primitive kernel-level 
interface and the hand-scanner interface by definition is limited to 
hand-scanners. In contrast, SANE is general enough to support any device that 
acquires raster images. The closest thing to SANE is probably TWAIN. 
-->
もちろん SANE がこのような汎用インタフェースの最初の試みではありません。
TWAIN, PINT, Linux hand-scanner というインタフェースを耳にしたことがあるかも
しれません。問題なのは，これらの古いインタフェースには、アプリケーションから
デバイスへの(またはその逆の)インタフェースが不足していることです。
例えば、PINT は本当にいくぶん原始的なカーネルレベルのインタフェースであり、
hand-scanner インタフェースは文字どおりハンドスキャナに限定されています。
対照的に SANE はラスター画像を取り込むデバイスをサポートするのに一般には充分
です。SANE に最も近いのは、たぶん TWAIN です。
<p>
<!--
The fact that the two rhyme is not coincidental, but that's a different story.
The main reason TWAIN is not SANE is that TWAIN puts the graphical 
user-interface to control the device in the driver instead of the application.
This makes it unsuitable for Linux or networked environments where the scanner
driver might run on one machine and the application on another. In contrast, 
SANE enforces a strict separation between the actual driver and the 
user-interface for its controls. Indeed, the current SANE distribution 
includes support for network-transparent scanning. 
-->
SANE と TWAIN の韻は偶然の一致ではないことは事実ですが、それは別の話です。
TWAIN が SANE ではない主な理由は、TWAIN がアプリケーションに代わってドライバ
の中にデバイスを制御するためのグラフィカル・ユーザインタフェースを置くことで
す。これは スキャナが動作しているマシンとは別のマシンでアプリケーションが動
いているといった Linux またはネットワーク環境には適していません。SANE はこれ
と対照的に、実際のドライバとそれを制御するアプリケーションの厳密な分離を強要
します。実際、現在の SANE ディストリビューションにはネットワーク経由でのスキャ
ンがサポートされています。
</quote>

<!--
2 Using SANE
-->
<sect> SANE を使う
<p>
<quote>
<!--
To start using SANE, fetch the latest version of the distribution from the 
ftp directory: 
-->
<p>
SANE を使うには下記の ftp ディレクトリから最新バージョンのディストリビュー
ションを入手します。<newline>
                 <url url="ftp://ftp.mostang.com/pub/sane/">
<p>
<!--
If you want to build the graphical-user-interface programs that come with 
SANE, you will also need to fetch, build and install the GIMP or, at a 
minimum, the GTK distribution. Both GIMP and GTK are available at 
ftp://ftp.gimp.org/. GTK is the user-interface toolkit that originally has 
been developed for the GIMP, but is now being adopted by many other projects, 
including SANE. Note that the SANE distribution will build just fine without 
the GIMP/GTK libraries. However, that way none of the nice graphical-user-
interface programs will be built, thus taking away much of the fun. 
So, unless you are building SANE for a server only, I recommend that you 
install at least GTK, if not GIMP. 
-->
SANE に付いてくるグラフィカル・ユーザインタフェースをビルドしたいなら、
GIMP あるいは最低限でも GTK を入手、ビルド、インストールする必要があります。
GIMP と GTK はいずれも <newline>
 <url url="ftp://ftp.gimp.org/"> <newline>
から入手します。GTK は元々 GIMP 用に開発されたユーザインタフェースのツール
キットですが、今では SANE を含む他の多くのプロジェクトに採用されています。
SANE ディストリビューションは GIMP/GTK ライブラリが無くてもうまくビルドでき
ます。しかし、その場合グラフィカル・ユーザインタフェース・プログラムは何ひと
つビルドされず、多くの楽しみが奪われてしまいます。従ってサーバ用のみに
 SANE をビルドするのでなければ、最低でも GTK (GIMPではなく) をインストール
することを勧めます。
<p>
<!--
After fetching the SANE distribution, unpack the compressed tar file and 
follow the instructions in the README file. The README explains how to build 
and install SANE. Also, take a look at the file called PROBLEMS; it contains 
a list of known problems and their work arounds. 
-->
SANE ディストリビューションを入手したら圧縮されている tar ファイルを展開し、
README ファイルの内容に従って下さい。README は SANE をビルドし、インストール
する方法を説明しています。また PROBLEMS というファイルにも目を通して下さい。
これには既知の問題点と、するべきことのリストがあります。
<p>
<!--
Note that you don't have to own a scanner or a camera to play with SANE. The 
distribution includes a pseudo-driver that simulates a scanner by reading 
portable ``anymap'' (PNM) files. Also, SANE is not limited to Linux. Besides 
Linux for Alpha, x86 and m68k, it includes support for AIX, Digital Unix, 
FreeBSD, HP-UX, IRIX, NetBSD, SCO, Solaris, SunOS, and even OS/2. 
-->
SANE を動作させるためにスキャナやカメラが必須ではないことに注意して下さい。
SANE ディストリビューションには、PNM (portable `anymap')ファイルを読むこと
によりスキャナをシミュレートする仮想ドライバが入っています。また、SANE は 
Linux に限定されません。Linux Alpha, Linux x86, Linux m68k 以外にも AIX, 
Digital Unix, FreeBSD, HP-UX, IRIX, NetBSD, SCO, Solaris, SunOS また OS/2 
でも動作します。
<p>
<!--
After installing SANE, you should be able to type the command 
-->
SANE をインストールしたら下記のコマンドを入力してみましょう。
<p>
    scanimage --list-devices
<p>
<!--
and get the output shown below: 
-->
すると以下のように出力される筈です。
<p>
    device `mustek:/dev/scanner' is a Mustek MFC-06000CZ flatbed scanner
<newline>
    device `pnm:0' is a Noname PNM file reader virtual device <newline>
    device `pnm:1' is a Noname PNM file reader virtual device
<p>
<!--
As the listing shows, in this particular case, a Mustek scanner is available 
under name mustek:/dev/scanner and two fake devices called pnm:0 and pnm:1 are
available that can be used to read PNM files. To get list of all options for 
a particular device, for example pnm:0, simply type: 
-->
この例では Mustek のスキャナは mustek:/dev/scanner という名前で利用可能で
あり、また pnm:0 と pnm:1 という PNM ファイルを読むために使う 2 つの仮想
デバイスも利用できることを、このリストは表しています。個別のデバイスの全
てのオプションを表示するには、例えば pnm:0 の場合、次のようにします。
<p>
    scanimage --device pnm:0 --help
<p>
<!--
This will produce the help message shown in Figure 1. 
-->
こうすると図1 のようなヘルプメッセージが出ます。
<code>
    Usage: scanimage [OPTION]...

    Start image acquisition on a scanner device and write PNM image data to
    standard output.

    -d, --device-name=DEVICE   use a given scanner device
    -h, --help                 display this help message and exit
    -L, --list-devices         show available scanner devices
    -v, --verbose              give even more status messages
    -V, --version              print version information

    Options specific to device `pnm':
      Source Selection:
        --filename <\<>string> [/tmp/input.ppm]
            The filename of the image to be loaded.
      Image Enhancement:
        --brightness -100...100% [0]
            Controls the brightness of the acquired image.
        --contrast -100...100% [0]
            Controls the contrast of the acquired image.
        --grayify[=(yes|no)] [no]
            Load the image as grayscale.
        --three-pass[=(yes|no)] [no]
            Simulate a three-pass scanner by returning 3 separate frames.  
            For kicks, it returns green, then blue, then red.
        --hand-scanner[=(yes|no)] [no]
            Simulate a hand-scanner.  Hand-scanners often do not know the 
            image height a priori.  Instead, they return a height of -1.  
            Setting this option allows one to test whether a front end can 
            handle this correctly.
        --default-enhancements
            Set default values for enhancement controls 
            (brightness & contrast).

            Figure 1: Scanimage Help Message For pnm:0 Pseudo-Device
            図1: pnm:0 仮想デバイス用 scanimage のヘルプメッセージ
</code>
<p>
<!--
The SANE package comes with a detailed man page that explains the specifics 
of the scanimage program. As an example, suppose we had a PPM file named 
input.ppm. We can use the scanimage program to ``scan'' that image and 
increase its brightness by 50% using the following command: 
-->
SANE パッケージには、Scanimage プログラムの使い方を説明した詳細なマニュアル
ページが付いてきます。例として input.ppm という名前の PPM ファイルを想定しま
す。下記のコマンドで、この画像を「スキャン」し、かつ明るさを 50&percnt;増加
させることができます。
<p>
    scanimage --device pnm --brightness 50 input.ppm > output.ppm
<p>
<!--
If you look at file output.ppm with an image viewer such as xv, you should be 
able to see that output.ppm is noticeably brighter. 
-->
xv のような画像ビューワで output.ppm ファイルを見ると、output.ppm が著しく
明るくなっていることが分かるでしょう。
<p>
<!--
You may say: cool, but where is the graphical user-interface? Assuming you 
had the GTK libraries installed when SANE was built, you can invoke a program 
called xscanimage that will present you with a dialog box containing a list of
available devices. If you double-click on the ``pnm:0'' entry, you'll get the 
dialog shown in Figure 2. 
-->
あなたはこう言うかもしれません − 「すごい。だけどグラフィカル・ユーザイン
タフェースはないの？」。SANE をビルドした時点で GTK ライブラリがインストー
ル済みであれば、xscanimage というプログラムを呼び出すことができます。
これは、利用可能なデバイス一覧のダイアログボックスを表示します。`pnm:0' を
ダブルクリックすると図 2 に示すダイアログが表示されます。
<p>
<!--
                              Figure 2: SANE Dialog Window
-->
<p>
&lt;&lt;  図2： SANE ダイアログウィンドウ &gt;&gt; <newline>
( <url url="http://www.mostang.com/sane/lj98/doc003.html">
  の Figure 2: SANE Dialog Window 参照 )
<p>
<!--
As you can see, the dialog includes two text-entry boxes labeled ``Filename''
and a slider labelled ``Brightness''. If you enter output.ppm in the first
text-entry box and input.ppm in the second box and move the brightness slider
to 50.0, you can press the Scan button at the bottom left and get the same 
result as with the scanimage command line shown above. Of course, before 
doing the actual scanning, you could press the Preview button at the bottom 
right to pop up a preview window (see Figure 3). 
-->
ご覧のようにダイアログには 2 つの `Filename' というテキスト入力ボックスと
`Brightness' というスライダがあります。最初のテキスト入力ボックスに
output.ppm , 2 つ目のボックスに input.ppm と入力し、Brightness のスライダを
 50.0 に移動させてから左下の Scan ボタンを押すと、前述のコマンドラインで
実行した scanimage と同じ結果が得られます。もちろん本番のスキャンをす
る前に、右下の Preview ボタンを押してプレビュー・ウィンドウ(図3) を表示
させることもできます。
<!--
                              Figure 3: SANE Preview Window
-->
<p>
&lt;&lt;  図3： SANE プレビュー・ウィンドウ &gt;&gt; <newline>
( <url url="http://www.mostang.com/sane/lj98/doc003.html">
  の Figure 3: SANE Preview Window 参照 )
<p>
<!--
In the preview window, you can push the Acquire->Preview button to obtain a 
low-resolution preview of the final image. For example, by moving the 
brightness slider around, you can see how the brightness of the image is 
affected. After moving the slider, you'll need to press the Acquire Preview 
button to get an updated preview. 
-->
プレビュー・ウィンドウでは、 Acquire -&gt; Preview ボタンを押すとスキャン
本番の画像を低解像度でプレビュー表示できます。例えば、Brightness スライダ
を操作すると、画像の明るさがどのように影響されるかが分かります。スライダ
を動かしてから Acquire Preview ボタンを押すとプレビュー表示が更新されます。
<p>
<!--
When scanning an image with a real scanner or camera, you'll usually want to 
enhance it in various ways, such as making it appear sharper. The nice thing 
about the xscanimage program is that it can also be run as a GIMP extension. 
To do this, simply create a symlink from the GIMP plug-ins directory to the 
xscanimage binary. Assuming the SANE installation defaults, you could do this 
with the following command: 
-->
スキャナやカメラで画像をスキャンする際、様々な方法の画像補正をしたいことが
よくあります(例えば画像をシャープにするなど)。xscanimage プログラムは幸いに
も GIMP の拡張として実行させることができます。このようにするには、GIMP の
 plug-ins ディレクトリから xscanimage のバイナリにシンボリックリンクを張る
だけです。SANE をインストールしたディレクトリがデフォルトと同じだとすると、
下記のコマンドでシンボリックリンクを張れます。
<p>
    ln -s /usr/local/bin/xscanimage &tilde;/.gimp/plug-ins
<p>
<!--
After making this link, xscanimage will attach itself to the GIMP's ``Xtns'' 
menu the next time you start it. This makes it possible to invoke, for 
example, the PNM pseudo-device by selecting ``Xtns->Acquire Image->pnm:0''. 
When invoked in this manner, pressing the Scan button will put the newly 
scanned image inside a GIMP window (instead of saving it to disk). Now, the 
usual GIMP image-manipulation functions can be used to enhance the acquired 
image before saving it. 
-->
シンボリックリンクを張ると、 GIMP の次回起動時から xscanimage は `Xtns'
(拡張) メニューに組み込まれます。これは `Xtns -&gt; Acquire' そして 
'Image -&gt; pnm:0' で PNM 仮想デバイスを選択することにより起動できるよ
うになります。この方法で起動する場合、Scan ボタンを押して新しくスキャン
した画像は(ディスクにセーブするかわりに) GIMP ウィンドウの内側に置かれま
す。これで、通常の GIMP の画像処理機能を、取り込んだ画像をセーブする前の
補正に使えるようになります。
<p>
<!--
The PNM pseudo-device may be fun, but what does a real scanner interface 
look like? Figure 4 shows the xscanimage dialog as it appears for Mustek 
flatbed scanners. The figure also demonstrates another feature of xscanimage: 
tool tips (also known as ``balloon help''). Tool tips make it easier for new 
users to get acquainted with the capabilities of their scanner or camera. 
In the figure, the mouse points to the Scan Source menu and, as a result, 
the help information for that menu is shown in the yellow box below the mouse 
pointer. Tool tips are handy for new users, but after a while, they tend to 
get in your way. Thus, xscanimage allows advanced users to turn off the tool 
tips using the Preferences sub-menu. 
-->
この PNM 仮想デバイスはちょっと変に見えるかもしれませんが、本物のスキャナ
インターフェースはどのように見えるのでしょうか？
図 4 は、Mustek フラットベッド・スキャナでの xscanimage ダイアログです。
この図は、xscanimage の他の機能：ツールチップ(バルーンヘルプとも言う)の
デモンストレーションも行っています。ツールチップがあれば、新規ユーザがスキ
ャナやカメラの能力を理解しやすくなります。図の中で、マウスは Scan Source 
メニューを指し、その結果このメニューのヘルプ情報がマウスポインタの下の黄色
い箱の中に表示されています。ツールチップは新規ユーザには便利ですが、しばら
くすると自分なりの方法でやりたくなります。そこで xscanimage は上級者向けに
 Preferences サブメニューでツールチップを出さないようにすることもできます。
<p>
<!--
                  Figure 4: Mustek Dialog Window for xscanimage
-->
<p>
&lt;&lt; 図4：xscanimage での Mustek ダイアログウィンドウ &gt;&gt; <newline>
( <url url="http://www.mostang.com/sane/lj98/doc003.html">
  の Figure 4: Mustek Dialog Window for xscanimage 参照 )
<p>
<!--
As you can see, the Mustek dialog looks quite different from the PNM 
pseudo-device interface. This is because the underlying devices have different
capabilities. In fact, the device dialog depends not only on the selected 
device, but also on the mode of the device. For example, when turning on the 
``Use custom gamma table'' option near the bottom of the dialog, the interface
changes, and the result is shown in Figure 5. As you can see, the right half 
of the dialog now contains a graph editor that allows the user to modify the 
intensity, red, green or blue gamma table. In other words, xscanimage displays
precisely the options that are active or meaningful for a given scan mode, 
greatly reducing the likelihood of confusing the user. 
-->
ご覧のように Mustek ダイアログは PNM 仮想デバイスインタフェースとはかなり
異なるように見えます。これは元になるデバイスが異なる能力を持っているから
です。デバイスダイアログは、選択されたデバイスに依存するだけでなく、デバ
イスのモードにも依存します。例えばダイアログの下の方にある `Use custom 
gamma table' オプションをオンにするとインタフェースが変更され、結果として
図 5 のようになります。ご覧のようにダイアログの右半分はグラフエディタに
なり、輝度と RGB のガンマテーブルを変更できます。言い換えれば xscanimage は
アクティブな、または与えられたスキャンモードでの重要なオプションを正確に表示
するので、ユーザが混乱しにくくなります。
<p>
<!--
          Figure 5: Mustek Dialog With Gamma Table Editor
-->
<p>
&lt;&lt; 図5：ガンマテーブルエディタ付き Mustek ダイアログ &gt;&gt; <newline>
( <url url="http://www.mostang.com/sane/lj98/doc003.html">
  の Figure 5: Mustek Dialog With Gamma Table Editor 参照 )
<p>
<!--
Looking at the image-intensity gamma table in the right half of the figure, 
you can probably imagine that it would be rather annoying to define the 
gamma tables each time you started xscanimage. Once the ideal tables have 
been found, it would be nice if it were possible to save them. For this 
purpose, xscanimage allows saving the current device settings through an
entry in the Preferences sub-menu. Once saved, whenever xscanimage is started,
it automatically restores the last saved option values for that device. 
-->
図の右半分にある画像の輝度ガンマテーブルを見ると、xscanimage を起動する度
にガンマテーブルを定義していたら、むしろいらいらするのではないかと思うかも
しれません。理想的なテーブルが見つかって、もしそれらをセーブすることができ
るなら素晴らしいですね。このために、xscanimage は Preferences サブメニュー
の項目で現在のデバイス設定をセーブできます。セーブしておけば xscanimage を
起動する度に、そのデバイスで最後にセーブされたオプションが自動的に読み込ま
れます。
</quote>

<!--
3 What Else Comes with SANE?
-->
<sect> SANE に付属するもの
<p>
<quote>
<!--
Now that you have seen how to use some of the programs that come with the 
SANE distribution, it is time to tell you what else is included. At the time 
of this writing, the package includes drivers for the following devices: 
-->
SANE ディストリビューションに含まれるいくつかのプログラムの使い方を見てき
ました。その他に何があるのかを書きます。これを書いている時点で、パッケージ
には以下のデバイス用のドライバが入っています。
<p>
<!--
    Connectix QuickCam (color and monochrome). 
    Some Epson SCSI scanners. 
    Hewlett-Packard ScanJet SCSI scanners. 
    Microtek SCSI scanners. 
    Mustek SCSI flatbed scanners
     (both one-pass and three-pass scanners are supported). 
    PINT devices: PINT is a Unix-kernel interface for NetBSD, OpenBSD and 
    SunOS. SANE's PINT driver provides access to any scanner for which
    there is PINT support. 
    Most UMAX SCSI scanners. 
-->
<itemize>
<item> Connectix QuickCam (カラーとモノクロ)
<item> Epson SCSI スキャナ
<item> Hewlett-Packard ScanJet SCSI スキャナ
<item> Microtek SCSI スキャナ
<item> Mustek SCSI フラットベッドスキャナ <newline>
       (1 パスおよび 3 パススキャナ のいずれもサポートされています)
<item> PINT デバイス <newline>
       PINT は NetBSD, OpenBSD, SunOS 用の Unix カーネルインタフェースです。
       SANE の PINT ドライバは PINT サポートがあるスキャナにアクセスできます。
<item> ほとんどの UMAX SCSI スキャナ
</itemize>
<!--
Support for many other scanners and cameras is planned and some of them 
should be ready by the time you read this article. For the latest information,
please visit the web page listed in the References. 
-->
他の多くのスキャナ、カメラのサポートは計画中で、その内のいくつかはこの記事を
読むまでの間に出来ているかもしれません。最新情報は参考文献のところに書かれて
いるウェブページを見て下さい。
<p>
<!--
Available applications are the command-line scanimage, the graphical 
xscanimage (either stand-alone or as a GIMP extension) and xcam, a graphical 
user interface suitable for cameras which produce a continuous stream of 
images (such as the Connectix QuickCam). 
-->
利用可能なアプリケーションは、コマンドラインの scanimage と グラフィカル
な xscanimage (スタンドアロンで、または GIMP の拡張として)と
(Connectix QuickCam のような)連続した画像のストリームを作るカメラに適した
グラフィカルユーザインタフェースの xcam です。
<p>
<!--
In addition, there are SANE API bindings for Python and Java API and a network
daemon called saned that provides network-transparent access to remote 
devices. Assuming you have the appropriate permissions, this makes it possible
to control a camera running in the U.S. from a machine running in 
Europe - - - all courtesy of SANE and the Internet. 
-->
加えて、SANE には Python や Java 用の API があり、またリモートデバイスへの
ネットワーク経由のアクセスを可能にする saned というネットワークデーモンが
あります。これはパーミッションを適切に設定してあれば、アメリカで動作して
いるカメラをヨーロッパにあるマシンから制御することもできます。これは全て 
SANE とインターネットのサービスによるものです。
</quote>

<!--
4 How Does It Work?
-->
<sect> どのように動作するか
<p>
<quote>
<!--
When building a SANE application, it must be linked against the shared 
library called libsane.so. In reality, libsane.so is just a symlink to one 
of the SANE drivers. Since every SANE driver exports the exact same 
interface, you can change the libsane.so symlink at any time and effectively 
change which driver the application is using. While this is useful in the 
sense that it allows upgrading to a different driver without having to 
relink all the applications, it would not be very convenient if you had to 
change a symlink whenever you wished to switch the scanning device. For this 
reason, SANE supports two pseudo-drivers called dll and net. They are 
pseudo-drivers because rather than talking to physical devices, they talk to
other SANE drivers, as illustrated in Figure 6. 
-->
SANE アプリケーションをビルドする際、libsane.so という共有ライブラリがリン
クされている必要があります。実際には、libsane.so は SANE ドライバ群の一つ
へのシンボリックリンクに過ぎません。どの SANE ドライバも同じインタフェース
を提供するので、いつでも libsane.so へのシンボリックリンクを変更できますし、
アプリケーションが使用しているドライバを効果的に変更できます。
全てのアプリケーションをリンクし直すことなくドライバをアップグレードできる
ため、ある意味これは便利ですが、スキャンデバイスを切替えたい時はシンボリッ
クリンクを変更しなければならず、かなり不便です。
このため SANE は、dll および net という 2 つの仮想デバイスドライバをサポ
ートしています。これらは仮想ドライバです − なぜなら物理的デバイスに話しか
けるのではなく、図 6 に示すように他の SANE ドライバと話すからです。
<p>
<!--
                           Figure 6: Possible SANE Hierarchy
-->
<p>
&lt;&lt; 図 6: 取りうる SANE 階層 &gt;&gt; <newline>
( <url url="http://www.mostang.com/sane/lj98/doc005.html">
  の Figure 6: Possible SANE Hierarchy 参照 )
<p>
<!--
For machine A, the libsane.so symlink points to the dll pseudo-driver 
(called libsane-dll.so). That pseudo-driver uses dynamically linked 
libraries (dll) to access other SANE drivers. In the example, dll is 
configured to use the pnm, mustek and net drivers.
-->
マシン A にとって、libsane.so のシンボリックリンクは dll 仮想ドライバ
(libsane-dll.so と呼ばれる)を指しています。仮想ドライバは他の SANE ドラ
イバにアクセスするためにダイナミックリンクライブラリ(dll)を使用します。
例示した図では dll は pnm, mustek, net ドライバを使うために設定されています。
<p>
<!--
The net driver is again a pseudo-driver; it provides access to remote 
scanners by connecting to the SANE daemon (saned) running on machine B. 
Machine B in turn uses dll again to provide access to a variety of other 
drivers. As you might imagine, the exact configuration is entirely up to 
the system administrator(s) of machines A and B. 
-->
net ドライバもやはり仮想ドライバで、これはマシン B で動作している SANE 
デーモン(saned)に接続することにより、リモートスキャナへのアクセスを提供
します。さて、マシン B は、他のいくつかのドライバにアクセスするために
再び dll を使用します。ご想像のように、システム管理者は、マシン A と B を
正しく設定しないといけません。
<p>
<!--
It is fairly typical to have libsane.so be a symlink to the dll 
pseudo-driver, but there is no reason it couldn't point to the net 
pseudo-driver or just the mustek driver.
Of course, in the latter case the implication would be that applications 
could access the mustek driver only - - - but that's perfectly reasonable
 for certain environments. 
-->
libsane.so を dll 仮想ドライバへのシンボリックリンクとするのは、普通に行わ
れるやり方です。でも net 仮想ドライバへのリンクにしたり、単純に mustek ドラ
イバへのリンクにしたりもできない理由はないはずです。
もちろん、例えば mustek にリンクさせた場合には、アプリケーションは mustek の
ドライバにしかアクセスできなくなるでしょう。
でも、これは特定の環境においては完全に合理的であるかもしれません。
<p>
<!--
This approach is very flexible, but it raises an interesting question: 
how do we name devices in such an environment? The answer is that every 
real driver has its own device name space. For example, the Mustek and HP 
drivers use the path for the Unix special device that controls the device, 
such as /dev/scanner. 
-->
このアプローチは大変柔軟ですが、興味深い質問が出てきます。
このような環境でデバイスの名前をどうやってつけるのでしょう？
答えは、リアルドライバは全てそれ自身の名前のスペースを持っている、です。
例えば、Mustek と HP ドライバはデバイスを制御する /dev/scanner のような Unix
スペシャルデバイスのパスを使います。
<p>
<!--
With pseudo-drivers, things get a bit more interesting. 
Since dll must guarantee that each device name is unique, it simply prefixes 
the name of each subordinate device with the name of the subordinate driver, 
separated by a colon. Thus, on machine A, the mustek scanner would be called 
mustek:/dev/scanner. The net pseudo-driver does something similar: it 
prefixes the remote device name with the remote host name (again using a 
colon as a separator). 
-->
仮想ドライバには、もう少し面白いことがあります。
dll は各ドライバ名がユニークであることを保証しなければならないので、
各々の従属デバイス名と従属ドライバ名をコロンで区切ったものを接頭辞として
つけます。従って、マシン A では mustek のスキャナは mustek:/dev/scanner 
と呼ばれます。net 仮想ドライバも同様に、リモートデバイス名とリモートホ
スト名を接頭辞としてつけます（やはりコロンがセパレータとして使われます）。
<p>
<!--
For example, HP scanner 1 on machine B would appear 
on machine A under the name net:B.domain.com:hp:/dev/scanner1. While this 
doesn't make for the world's prettiest names, the information contained in 
the names is actually quite useful. 
-->
例えば、マシン B の HP スキャナ1 は、net:B.domain.com:hp:/dev/scanner1 
という名前でマシン A に現れます。野暮ったい名前ですが、名前に含まれる情報
は実際に極めて有用です。
<p>
<!--
In essence, much like a Unix path name,the device names convey the path 
through the SANE hierarchy that leads to a particular device. For example, 
if you know that machine B is down, it's pretty obvious that 
net:B.domain.com:hp:/dev/scanner1 will be down as well. 
-->
デバイス名は SANE の階層を通して個々のデバイスへ割り振られます
(本質的には、Unix のパス名に似ています)。
例えば、マシン B がダウンしたことが分かれば、
net:B.domain.com:hp:/dev/scanner1 も同じようにダウンしていることは、明白
です。

<p>
<!--
If someone feels strongly about these names, it is possible for an 
application to let a user or system administrator define aliases that are 
more concise. 
For example, an application could let a user rename the above device to 
``HP Scanner 1'', which may be easier for beginners. 
-->
これらの名前がすごく嫌なら、ユーザまたはシステム管理者が、アプリケーション
を簡潔なエイリアスで定義することもできます。
例えば、ユーザがアプリケーションで上記デバイス名を(初心者には分かり易い) 
`HP Scanner 1' にリネームできます。
</quote>

<!--
5 Programming With SANE
-->
<sect> SANE のプログラミング
<p>
<quote>
<!--
By definition, SANE is only as good as the programs that use it. This means 
the more applications and the more devices that use SANE, the merrier. 
The SANE distribution comes with a detailed document that explains the SANE 
API; however, the interface is quite simple. The six main functions are 
listed below: 
-->
定義により、SANE はそれを使うプログラムと同じくらい良い唯一のものです。
これは、SANE を使用するアプリケーションやデバイスが多い程、より楽しくなる
ことを意味します。SANE ディストリビューションには、SANE API を説明した
詳細なドキュメントも付いてきますが、インタフェースは極めてシンプルです。
下記に示す6個のメイン関数があります。
<p>
    handle &lt;- sane_open (device-name):
<!--
        allows you to open a SANE device by name (e.g., pnm:0). 
-->
<quote>
        SANE デバイスを名前 (例えば pnm:0)でオープンします。
</quote>
    sane_close (handle):
<!--
        allows you to close a SANE device. 
-->
<quote>
        SANE デバイスをクローズします。
</quote>
    sane_get_option_descriptor (handle, option-number):
<!--
        is used to query the controls available to the device (such as the 
        brightness control in the PNM pseudo-device driver). 
-->
<quote>
        デバイスが利用可能な制御はなにかを問い合わせるために使われます
        (PNM 仮想デバイスドライバの明るさ制御のような)。
</quote>
<p>
    sane_control_option (handle, option-number, action, value):
<!--
        is used to get or set the value of an option. For example, it can 
        be used to set the value of the brightness option to 50 percent. 
        In addition, some options support an auto-mode where the driver 
        picks a reasonable value. For such options, sane_control_option() 
        can also be used to turn auto-mode on or off. 
-->
<quote>
       オプションの値を取得または設定するために使われます。例えば、明るさの
       オプションの値を 50&percnt; にセットするために使われます。加えて、
       いくつかのオプションはドライバが適切な値をとるようにする自動モードを
       サポートしています。このようなオプションでは、sane_control_option()
       は自動モードをオンまたはオフにするためにも使われます。
</quote>
    sane_start (handle):
<!--
        is used to start the acquisition of an image. 
-->
<quote>
       画像の取り込みを開始するために使われます。
</quote>
    bytes-read <- sane_read (handle, buffer, buffer-size):
<!--
        is used to read the actual image data until the entire image has 
        been acquired. 
-->
<quote>
       全ての画像を取り込むまで、実際の画像データを読むために使われます。
</quote>
<!--
The SANE API is simple by design. The goal was to make it possible to 
accomplish a simple task in a small amount of time while still providing 
enough functionality to enable sophisticated drivers and applications. 
The simplicity is best evidenced by the fact that it took just two evening 
sessions to convert the hpscanpbm program into a SANE driver for HP scanners.
On the other end of the spectrum, the Mustek driver and xscanimage are 
fairly complicated programs and SANE had no problems accommodating them. 
-->
<p>
SANE API はシンプルに設計されています。目標は、洗練されたドライバとアプリ
ケーションを可能にする充分な機能を提供しながらも、シンプルなタスクを少ない
時間で成し遂げることでした。HP スキャナ用の hpscanpbm プログラムを SANE 
ドライバに変換するのに要したのはふた晩という事実は、設計のシンプルさの最良
の証拠です。逆に、Mustek ドライバと xscanimage はかなり困難なプログラムで
すが、SANE はそれらに順応するのに問題はありません。
</quote>

<!--
6 SANE and Commercial Applications/Drivers
-->
<sect> SANE と商用のアプリケーション／ドライバ
<p>
<quote>
<!--
What's our position with respect to commercial SANE drivers or applications? 
In the spirit of the GNU Public License, it is preferrable to have the 
source for SANE programs available. However, it is permissible to write a 
dynamically loaded, commercial SANE driver on Linux and other platforms 
that support dynamic loading. (Drivers are always dynamically loaded, so 
this doesn't cause any extra work.) By the same token, it is also proper to 
write a commercial application that links with the libsane.so shared library. 
The basic ideas supporting this position are: 
-->
商用の SANE ドライバまたはアプリケーションに関する私たちの見解は
何でしょう？ GNU Public License の精神によれば、SANE プログラムのソースを持つ
ことは好ましいことです。しかし、ダイナミックロードされる、Linux と他のプラ
ットホーム用のダイナミックローディングをサポートする商用 SANE ドライバを書
くことは許されます
(ドライバは常にダイナミックロードされるので、これは特別な作業を生じません)。
同じ理由で、共有ライブラリ libsane.so にリンクする商用アプリケーションを
書くのも正しいことです。この見解を支える基本的な考え方は以下の通りです。
<p>
<!--
  1.Healthy competition between commercial and free programs is an asset, 
    not a liability. 

  2.The more wide-spread use SANE finds, the better for the Linux/Unix 
    community. 
-->
  1. 商用とフリープログラムの健全な競争は財産であって負債ではない。
<p>
  2. より幅広く SANE が使用されれば、Linux/Unix コミュニティにとってさらに
     よい状況になる。
</quote>

<!--
7 Future Plans
-->
<sect> 将来の計画
<p>
<quote>
<!--
In the immediate future, the plan is to add support for many more devices. 
For example, Agfa and Plustek scanner and Nikon filmscanner drivers are 
planned, and there is hope that drivers for some of the more popular digital 
cameras will materialize soon as well. To get the ultimate in network 
connectivity, there are also plans to implement a scanner application in Java,
making it possible to control your scanner from your favorite Java-enabled 
web browser. 
-->
ごく近い将来の計画は、もっと多くのデバイスのサポートを追加することです。
例えば、Agfa と Plustek のスキャナ、Nikon フィルムスキャナのドライバが計画
されています。また、よりポピュラーなデジタルカメラのドライバが間もなく実現
する可能性があります。ネットワークの接続性で最良のものを得るために、Java の
実行が可能なウェブブラウザからスキャナを制御できる Java のスキャナアプリケ
ーションを実装する計画もあります。
<p>
<!--
In the long term, it would be interesting to generalize SANE to embrace other 
multimedia devices including audio sources or video tape recorders. 
-->
長期計画では、オーディオソースやビデオテープレコーダを含む他のマルチメディ
ア・デバイスをSANE が包含するのが一般化することに興味があるでしょう。
<p>
<!--
In other words, SANE has just started, and there are many exciting projects 
to come. If you're interested in pursuing some of these by all means get in 
touch with other developers through the SANE mailing list. The mailing list 
and other valuable resources can be found at the SANE home page at 
http://www.mostang.com/sane/. 
-->
言い換えれば、SANE は始まったばかりです。そして多くのわくわくするようなプロ
ジェクトがあります。あなたがあらゆる意味で、これらのどれかに参加すること
に興味があるなら SANE メーリングリストを通して他の開発者と文通して下さい。
メーリングリストと他の価値あるリソースが SANE のホームページにあります。
<p>
<url url="http://www.mostang.com/sane/">
</quote>

<!--
Acknowledgments
-->
<sect> 謝辞
<p>
<quote>
<!--
The SANE project would not have been possible without the continued support 
of many people. In particular the contributions by Andreas Beck, Gordon 
Matzigkeit, Patrick Reynolds, and Tristan Tarrant were crucial to transforming
SANE from a dream into reality. 
-->
SANE プロジェクトは、多くの人達の継続的なサポート無しにはやってこれなかった
でしょう。中でも、Andreas Beck, Gordon Matzigkeit, Patrick Reynolds, 
Tristan Tarrant による貢献は、SANE を夢から現実のものに変換するために決定的
でした。
<p>
<!--
I would also like to thank Michael K. Johnson and Jeremy Rosenberger for 
their feedback on an early draft version of this article. 
-->
同様に Michael K. Johnson と Jeremy Rosenberger が、この記事の初期の
ドラフトバージョンのフィードバックをくれたことにも感謝します。
</quote>

<sect> 日本語版について
<p>
<quote>
  この文書は Linux Journal Issue 47, March 1998 に掲載され、SANE のホーム
  ページ <url url="http://www.mostang.com/sane/">
  で "Tutorial" として公開されている文書を翻訳したものです。
  翻訳および公開することに関し SANE プロジェクトの了承を得ました。
<p>
  履  歴： 第１版 1999年7月13日
<p>
  版権等： オリジナルの文書と同様に、この日本語版も GPL(GNU General Public
 License)に従います。
<p>
  謝  辞：日本語版作成にあたり、以下のJF メンバーの方に御協力頂きました。
          有難うございます。
<quote>
          福島 於修さん &lt; fuku@amorph.rim.or.jp &gt;   <newline>
          武井 伸光さん &lt; takei@cc.kochi-u.ac.jp &gt;  <newline>
          中野 武雄さん &lt; nakano@apm.seikei.ac.jp &gt; <newline>
          Hiro Sugawara さん &lt; hiro@arkusa.com &gt;
</quote>
<p>
  連絡先： 日本語版の誤訳等の指摘、質問、改良に関する提案、ご意見等は
           Ｒ．川岸 &lt; <htmlurl url="mailto:kawagisi@yk.rim.or.jp"
                                        name="kawagisi@yk.rim.or.jp"> &gt;
           または JF プロジェクト
           &lt; <htmlurl url="mailto:JF@linux.or.jp"
                               name="JF@linux.or.jp">&gt; 宛にお願いします。
</quote>
</article>
