Virtual OS/2 International Consumer Education
VOICE Home Page: http://www.os2voice.org
June 2005

Newsletter Index
< Previous Page | Next Page >
Feature Index

editor@os2voice.org


Scanner use in OS/2 and XFree86

By Bryann Melvin © June 2005

In order for OS/2 to be fully functional in almost any environment today the ability to scan documents is usually a necessity. If you are using XFree86 on OS/2 that necessity still remains as does that of a scanning frontend.

It would seem that the best program to use with the SANE libraries would be one made to use in the normal OS/2 environment. At first glance using Tame/2 in the WPS for scanning duties would be probably the best bet. However, we have found it desirable to scan into the GIMP for editing, Additionally, we have found scanning with Tame/2 to have some quirks that are a nuisance, at least with the scanners we use here (UMAX).


XSane running as a GIMP plugin (Pic is Baboquivari Copyright 2003 Bry Melvin)
(Click to see larger image.)

I don't know if this applies to all scanners in Tame/2... but with my UMAX scanners it was very problematic. The program worked... somewhat... but it would give a distorted aspect ratio in the preview window. In the above illustration we see a pic scanned into the GIMP on X using the XSane plugin. Behind it partially obscured you see the preview. Note the shape of this pix. Now, see the preview from Tame in the illustration following:

This would sometimes straighten itself out on a second preview run. It also seems to scan correctly if you set the scan size before running the preview. Here it is done that way: a 4 by 6 inch print from 35mm film was the scanned object ...so we set it at that. To eliminate white space on the borders you might want to set it slightly smaller.

Other times it would fix itself when doing the actual scan and then leave a white area at the bottom of the scanned pic. This is usable as it can be edited, but who wants separate steps? Tame also can't put the image directly into an image editor as versatile as the GIMP. Additionally this program has awkward ways of correcting gamma. It doesn't appear on the default panel, you have to select it -- not significant but I find the arrangement for XSane more intuitive. After using Tame/2 you end up with images stored in a Tame/2 Images directory by default. It also numbers them sequentially by default. This is a pretty good scanning solution for casual work. For scanning directly into an image editing and manipulation program, however, there is a better solution.

Although not without problems, XSane working from inside the GIMP has proved to be the best bet as a stand-alone scanning solution. XSane has more problems installing than Tame/2. The viewer incorporated into the package is poor: too large and awkward, at least in comparison with the GIMP. When using GIMP you get a display of the picture that is reduced ...in our example to 20% in size. A high-resolution scanning in XSane as a stand-alone application is going to give a large image, as seen in the next illustration, with only a piece of it visible on the screen. An additional bit of good news for some is that we got XSane working as a plugin without a Unix shell. As stand-alone we did not have such luck. An alternative to GIMP in manipulating scanned images could be to use XV, EE (Electric Eyes), or Imagemagick to display or work with the images. For initial scanning and editing, GIMP seems to be by far the best bet, however. Additionally, XSane has other features that can be used to integrate with mail, etc. We haven't tested XSane as a scanning interface for fax and email... although such an integrated solution would be nice to have for many. We'll leave that for a potential future essay.


(Click to see larger image.)

Getting the program to run as a GIMP plugin is seemingly much simpler than getting the program working as a stand-alone. We initially started experimenting with this for the article by disabling our Unix shell. We found this didn't work very well so left it alone and moved on to the GIMP plugin. We recommend if you have any intention of using XSane as a stand-alone application that you have a full Unix-like environment. Most importantly for many uses with a minimal Unix-like environment XSane will run as a GIMP plugin without a Unix shell. This, however, assumes you have GIMP and its plugins working. After trying to run it without our usual bash shell, we found it generated several error messages in a terminal. It did run adequately as a GIMP plugin. GIMP is much more useful as a viewer than the default viewer in XSane. Having used earlier ports of XSane and XScanimage along with early SANE ports I didn't anticipate too many problems. I did want to have the OS/2 (actually eCS 1.14) computer roughly equivalent to its SuSe 7.3 partner. I have both these computers set up with the same programs and window managers (GIMP 1.22, Imagemagick, etc.). To the user it is pretty much the same to work no matter which one you are on. I had used Tame/2 experimenting with scanning in the native desktop of OS/2 already, so there was already a copy of SANE ported to OS/2 on the computer. So I started on the X installation with XSane 0.96 for OS/2.

The downloadable ZIP file for XSane is made to fit into the XFree86 tree. The readme is included in the ZIP. I recommend extraction of this file using a file manager such as FM/2 and printing the readme and reading it thoroughly prior to installation.

The documentation (readme) gives several DLLs that need to be in the LIBPATH.

All of these are already installed in my system. If you have installed GIMP, then all of these should be and if you've installed fixed /checked GIMP with the instructions I added in the GIMPATCH docs I wrote a while back, you have them too... with two exceptions:

Zlib114: I have and had published installation with Zlib113. The earlier version on my computer seems to work OK. I didn't change it. Zlib114 is available from OS2Ports as part of an updated graphics package for XFree86. I downloaded it... but haven't tried it yet as my current Zlib113 seems to work OK... at least with the GIMP.

This XSane read me also calls for iberty.dll.

This was an elusive item. The address to obtain this DLL in the readme is a dead link. Searching Hobbes and OS2site.com came up empty as did searching OS2ports. I'm not aware of what this DLL is for! But I couldn't find it anywhere. I have been informed that it is in emx/lib on some versions of emx... It's not on mine even with emx gcc and other programming/porting tools installed. [The DLL is part of the distribution of some later ports of the gcc compiler. - Ed.]

The good news is that this program works as a GIMP plugin without it. It also seems to work as a stand-alone without this also.

Continuing on with the instructions one must have a libsane.dll from SANE 1.05 or later in the LIBPATH. I used the same version (1.0.14) that I had used in Tame/2. I copied it into the XFree/unixos2 tree. (This is an area where it would be nice to have a ln command in unixos2), unfortunately using OS/2's shadows doesn't work here.

It also needs to be set up. If you've used SANE or Tame/2 this should already be good to go. If not, you'll need to refer to the docs for SANE and Tame/2 and get it working... or if you have just installed SANE, use the command line to set things up for your particular scanner. Although I am unhappy with Tame/2 for my scanner and usage, the program has excellent help files to set things up with. It gets an A there. The help files included with Tame/2 are great.

In reality, most people will probably want to set up Tame/2 so they can scan from either the OS/2 desktop or X. I would agree that this probably would be the way to go and I recommend setting up Tame/2 to work from the OS/2 desktop, and then setting up XSane for use with GIMP. Once you have Tame/2 working by following the excellent docs, it is then a breeze to add XSane for XFree86 and set it up as a GIMP plugin.

I won't go into the Tame/2 installation in detail, as a careful step-by-step installation with the docs will get a working scanner in no time. The only problem would be if you had to search SANE sites for a newly supported scanner.

To continue with the XSane installation; quoting the XSane Docs:

Make sure that you have a working libsane.dll from SANE (1.0.5 or later) in your LIBPATH.

OK we mentioned this. If Tame/2 is working this should be good to go.

Set up SANE correctly. That means scanimage -L should find your scanner.

Again, if Tame/2 is already operational this should be OK. Otherwise test Sane from the command line as shown here.

Next step is to unpack XSane into the XFree86 tree. The zip file is setup to be unzipped into X11ROOT.

Hint here: I always unpack into a temporary directory and move. This lets you know if you are replacing a file you put there for something else! Stick to the placement. Trying to use a Linux-like arrangement say as in /opt or /usr/local/ is going to give you headaches. From the readme:

XSane won't work if it does not find the files in \XFree86\share\sane\XSane exactly in this place!

Note the location. Resist the temptation to put it somewhere else.

To use XSane as a GIMP plugin copy x:\xfree86\bin\xsane.exe to x:\xfree86\lib\X11\.gimp-1.2\plug-ins\xsane.exe.

This step is mandantory for plugin use...which I think is the best way to use XSane as it gives you the best tools for image manipulation. If you happen to be using the manpage...and not the readme for setting this up, be aware that the manpage tells you to link not copy...this has not been corrected from real Unix to unixos2. OS/2 needs a copy placed here.

Although national languages are supported I have only tried the English. The read me does have additional steps for National Language Support.

XSane needs a /.sane subdirectory in the home directory. This structure is typical of most apps in XFree86.

A subdirectory /xsane with some files should be generated when XSane is first started. This is the place where XSane saves its settings.

How XSane works can be different depending on how much and how strict of a Unix environment you have set up on your OS/2 machine.

(For details to set up a Unix-like environment have a look at The OS/2 Files.)

Depending how your system is set up you may need to compare this with the unixos2.org setup and adjust things accordingly.

The README recommends setting SANE_CONFIG_DIR in CONFIG.SYS (for example: SET SANE_CONFIG_DIR=g:\home\.sane) and store the SANE configuration files (dll.conf, 'scanner-model'.conf, and net.conf) in this directory.

Careful here ...especially if you are not using the same SANE libs for XSane and Tame/2.

The documentation remarks that a browser is needed to view the help files. It recommends the extremely outdated Mosaic. This is easily used, but it would be nice to use either XWarpzilla or better the Gnome help browser (another project for a rainy day...In the readme the author (of the 0.96 port) offers assistance in the form of a binary to use a PM Web Browser.) I would think making the text of them into manpages would work too.

One point of confusion for me was this from the README:

Edit XSane.cmd in x:\XFree86\bin and make an object for it on your desktop and start it.

I have been informed that this item is for users of HOBLink etc. I have an icon in the XFM Application Launcher, and have added it to my GNOME menus and window manager menus.

Actually, I couldn't find this CMD file in the distribution of XSane that I downloaded. There is a command file to start XSane in its stand-alone mode, but it is named differently. The included CMD file (XSane-start.cmd) works well but be sure to edit it to fit your configuration.

I suppose you could write a command file to start X and XSane and then exit it after use, but it is much better on the whole to start X just once and then use [CTRL-ESC] to go to the WPS and leave X running to re-enter when needed. X can do funny things to the computer when jumped in and out of continually. Leaving it running is the key to stability here. Once it is swapped out, you won't even notice it's there on most systems.

A word of caution, however. Should it (XFree86) try to restart on a reboot you could have a mess. Should your computer freeze etc. and require a reboot, if you don't have your CONFIG.SYS set not to restart apps after a reset, make sure that you use the [CTRL-SHIFT-F1] option if you've had a crash with X running in the background. Unfortunately, crashes are more frequent in recent OS/2 use as many of the ported apps are actually windows apps in wrappers (like OO etc.).

If you want to use copy mode, you need Ghostscript for OS/2. Be sure to read the documentation for both Ghostscript and XSane pertaining to this function.

Careful here too! The docs refer to GS 8.14. I am not using GS 8.14 in X myself. I'm using 7.03 and GV 3.58 on X11. I haven't tested out using this version in X.

The mail mode recommends using Electric Eyes. This is another useful graphics program for XFree86 on OS/2.

A note here: although I don't use the mail mode myself, Electric Eyes and Imagemagick coupled with GIMP 1.22 probably together make the best graphics suite available that runs in OS/2 (albeit on X of course). This combination is a potential future article.

Potential Problems

If windows don't work properly try another window manager. Our favorite configuration here is to start XFree86 with the Blackbox window manager. This has an editable menu where you can start other window manages from within Blackbox.

We have tested XSane with Blackbox, Enlightenment, and fwvm2.

One warning: With some scanners if you try to interrupt the scanning with a cancel, you may trigger an X server crash. Resist the temptation. Let the scanner do its scan; make the necessary changes and rescan. This will keep you from having a trap in the middle of doing your scanning work.

XSane in my opinion is best used from inside the GIMP. This gives a much better choice of how to save the files you scan as GIMP supports many more types of graphics files than the scanning software does on its own.

Tame/2 is also quite functional and actually quite easy to install. Both work with pretty much the same set of scanners. Both frontends for the SANE libraries and are compatible with each other on the same computer.

Jpeg.dll in Java 142.0x is a known culprit for problems it affects GIMP and other X apps. This is caused by the fact that Win32 ports (ODIN, INNOWIN) add duplicate DLLs that will interfere with Unix ports. One Example is Innotek Java's jpeg.dll. If this is anywhere in the LIBPATH, Unix graphic ports won't work.. or the Windows ports will quit working depending on LIBPATH sequence. This does not mean that the popular Innotek apps cannot be run on a computer with Unix ports. It means that you depend on the registry for them (like windows) and leave them out of the LIBPATH. Back some time ago with the first Innotek Java there was a rash of posts in users groups saying that this Java needed to be in PATH and LIBPATH. This is not the case. This can actually cause a lot of problems.

Some X ports need or at least operate better when a Unix shell is operative on the computer. After all you can be sure that the porter of the app has such a system. This is complicated by the fact that there is no standard unixos2 system (yet). Granted some are working to that goal but it is not anywhere near a reality yet.

There are work-arounds to make ported Unix apps work on OS/2 without a Unix shell...the gimpatch we have on our website is one such workaround, however we recommend having at least a bash shell available on your computer.

A little Background

Although I haven't published or released much lately, I am still working on trying to get a coordinated set of XFree86 Apps on OS/2 and XFree86. This project started as a means of getting GIMP to work as fully as possible on XFree86. It expanded so that we (Melvin Graphics) could work from X without having to revert back to the native OS/2 desktop, as we had decided on X11 apps as the best option of available graphics software that will run on OS/2. Another factor was compatibility as we switched most of our Microsoft operating system machines to Linux software.

As this is a graphics project, I've been trying to get a set of apps to include scanning and CD writing to work along side the GIMP in XFree86 on OS/2. This route has proved somewhat difficult and time consuming. But after about a year of tweaking this, we have an OS/2 computer that runs GIMP, XSane, XCDRoast, Electric Eyes, and Imagemagick, making a quite useful graphics workstation. We can also manage files from within X with XDIR or XFM, and do some text editing with programs like the Gnome editor and Lyx.


XDIR and Gedit on eCS, using XFree86 and Blackbox WM
(Click to see larger image.)

Miscellaneous info

There is no special support for XSane for OS/2. But there is a mailing list. Search for sane-os2 at Yahoogroups. You can also ask Franz Bakan and perhaps he can help.

GIMP1.22 Gimpatch and various other utilities and questions concerning this article can be found at or directed to http://www.melvinart.com.

GIMPATCH is a work-around for GIMP on OS/2 that does not run its install script correctly and thus will not run ...or will not run the plugins.

We can do limited email or group support for the XFree86 on OS/2 apps that we use at melvinart.com. Please be aware that computer software is not our primary function. We will get back to you on a first come first served basis, but artwork clients have priority on our time.

Contact brymelvin@melvinart.com or OS2_at_work group on Yahoo Groups.

References:

SANE for OS/2: http://home.tiscalinet.de/fbakan/sane-os2.htm
SANE project: http://www.sane-project.org
XSane for OS/2: http://home.tiscalinet.de/fbakan/xsane-os2.htm
XSane project: http://www.xsane.org
OS2ports.com: http://www.os2ports.com
UnixOS2.org: http://unixos2.org
Setting up a Unix-like environment: http://www.os2world.com/os2files/xfree86/unix_environment.html
SANE for OS/2 Yahoo group: http://groups.yahoo.com/group/sane-os2
OS/2 at Work Yahoo group: http://groups.yahoo.com/group/OS2_at_work
Melvin Art: http://www.melvinart.com


Feature Index
editor@os2voice.org
< Previous Page | Newsletter Index | Next Page >
VOICE Home Page: http://www.os2voice.org