VOICE Home Page: http://www.os2voice.org | July 2001 [Newsletter Index] [Previous Page] [Next Page] [Features Index] editor@os2voice.org

##
ImpOS/2 revisited

By Manfred Agne ©June 2001

ImpOS/2, a bitmap oriented image manipulation program, has been around for many years. Version 2.1 dates from April 1998, and this is still the latest. However, the package also includes drivers for some SCSI scanners, and these drivers have been updated from time to time. The latest drivers were released in April 2001, and they are available from http://www.compart.net.

Currently, I use it with a flatbed scanner (Microtek ScanMaker 630), and a slide/film scanner (Microtek ScanMaker 36t+). Both are SCSI attached. The flatbed scanner is an older model, but the slide scanner is still available, at least in Europe.

Compared to the image editing programs available on other operating systems, ImpOS/2 looks a bit outdated. On OS/2, Embellish and Gimp are interesting alternatives. However, there is one particular feature which I have not yet encountered in any other image editing program:
Most functions in Impos can be controlled via REXX. This may not sound very useful in an image manipulation program, but it means that the possibilities of Impos can be easily expanded, and combined with other programs.

Maybe I should also add that ImpOS/2 is a slim program. The latest version comes on a CD-ROM which includes both an English and a German languange version, but it would easily fit on a couple of floppy disks. Despite it's small footprint (both in terms of memory and disk space usage), Impos is quite flexible in it's appearance. After installation, the program looks as follows:

The "ImpOS" window is the programs main window, and the "tools" window can be opened via thebutton. If it's still open when you close Impos, it will pop up automatically the next time the program is started.

The buttons within the windows can be rearranged by simple drag and drop. Just pull them where you want them! Note that you can also drag and drop buttons from the tools window to the main window, and vice versa. Every button has a pop-up menu, and a settings dialog accessible therefrom. Oddly, only one settings dialog can be open at the same time.

Looking at the settings of the predefined buttons, one notices that the function called by a button can be changed. For example, when I installed Impos, one of the color conversion buttons (I can't remember which one) called the "wrong" function, i. e. the description text did not match the action performed. It's easy to correct that bug. Just modify the settings to point to the correct function, and you are done. In fact, Impos is even more flexible: Using the function `ImgExecMacro()`, an Impos button can be configured to call an external REXX program.

Let's try a simple example:

First, we need to write our REXX script, e. g. `D:\tmp\test.cmd`:

>     /* REXX */
>     call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
>     call SysLoadFuncs
>     RC=RxMessageBox('Hello world !','','OK','EXCLAMATION')
>     exit

Then, we drag and drop a button from the Impos setting window to the main or tools window, and configure it to call the REXX program that we just wrote:

> `ImgExecMacro('D:\tmp\test.cmd')`

In the other two fields, a brief description for the fly-over help (upper field), and a longer, more explicit help for the context-menu entry can be entered, if desired. Close the settings dialog to save the changes. Click on the newly created button to execute the REXX program.

Obviously, a "Hello world" tool is not that useful in an image manipulation program. Therefore, I decided I should present something which is a bit more interesting: A routine which can be used to automatically create thumbnails for all images within a given directory. For this next example, we will use mainly the internal image manipulation routines of Impos, most of which are also accessible via REXX.

This REXX program looks as follows:

    /***************************************************/
    /* REXX: rescale to max. size of 300 x 300 pixels  */
    /***************************************************/

    call RxFuncAdd 'SysLoadFuncs','RexxUtil','SysLoadFuncs'
    call SysLoadFuncs
    call RxFuncAdd 'ImgInitiate','ImpRexx','ImgInitiate'
    call ImgInitiate

    maxxy=300
    sourcepath='J:\'
    sourcepath=DlgEntry("Sourcepath:",sourcepath, "Sourcepath:")
    if substr(sourcepath,length(sourcepath),1)='\'
      then NOP
      else sourcepath=sourcepath||'\'
    targetpath=sourcepath||'THUMBS\'
    call SysFileTree sourcepath||'*.JPG','bilder','F'
    DO i=1 to bilder.0
      bild = word(bilder.i,5)
      thumbname = targetpath||right(bild,length(bild)-(length(sourcepath)))
      call SysFileTree thumbname,'result','F'
      if result.0=0   /* thumbnail image does not yet exist */
      THEN DO
        numImg = ImgLoadImage(bild,FALSE)
        width  = ImgQueryImageInfo(numImg,1)
        height = ImgQueryImageInfo(numImg,2)
        wfact = maxxy/width
        hfact = maxxy/height
        IF wfact > hfact THEN
         DO
           width  = maxxy
           height = TRUNC(height*wfact)
         END
         ELSE
         DO
           width  = TRUNC(width*hfact)
           height = maxxy
         END
         rc = ImgResizeImage(numImg,1,width,height,TRUE)
         filename = targetpath||right(bild,length(bild)-(length(sourcepath)))
         rc = ImgSaveImage(numImg,filename,'JPG','JPEG',FALSE)
         rc = ImgCloseImage(numImg)
       END
     END
     /***************************************************/

First, the RexxUtil Rexx extensions are loaded. When the script is only to be run from Impos, the lines

    call RxFuncAdd 'ImgInitiate','ImpRexx','ImgInitiate'
    call ImgInitiate
    are not necessary. However, I included them, because I wanted to be able torun the script from a WPS program object.

The program then defines a default path for the files to be converted, and opens a dialog box to allow the user to modify that path. The thumbnails will be created in the subdirectory 'THUMBS' of that path, which is assumed to exist.

Then, the program looks for all JPG files in the sourcepath. For each of these files, it checks whether a corresponding file already exists in the thumbnail directory. If it doesn't, then the script loads the image, determines the scaling factor, and rescales the image. The rescaled image is then saved in the thumbnail directory.

Note that I did not include any error checking. The source path and thumbnail directory are assumed to exist, and the program does not check whether there is sufficient disk space. In principle, wherever there's an 'RC=...' statement in the code, the result of the function should be checked, and proper error handling added. This is left as an exercise for the reader :-))

If you'd like to start writing your own image manipulation scripts for Impos, you should of course first have a look at it's own functions. They are documented in the REXX programming reference that's installed with Impos. If you'd like to go further, I can recommend the NETPBMA and PBMPLUS packages, both available from www.leo.org. They provide a large number of powerful command line image manipulation tools, some with functions that are not available in Impos. There's some overlap between the two packages, but it's worth while getting both. Impos can read and write the PNM format, and therefore, using Rexx it is possible to save an image to PNM, call one or more command line tools to modify the saved image, and then re-import the result. If you have problems with the re-import, you may want to go via the TIF format, which can be created using the PNM2TIF program that comes with the packages.

References: Compart: http://www.compart.net PNMPLUS: ftp://ftp.leo.org/pub/comp/os/os2/leo/graphics/pbmplus.zip NETPBMA: ftp://ftp.leo.org/pub/comp/os/os2/leo/graphics/netpbma.zip

Features
editor@os2voice.org
[Previous Page ] [Index] [Next Page ]
VOICE Homepage: http://www.os2voice.org