Chapter 11. Enhancing Impressario With Plug-Ins

This chapter explains how you can add plug-ins to Impressario to satisfy needs that haven't been integrated into the base software. This allows you to dynamically update the Impressario feature set.

The following topics are discussed in this chapter:

How the Impressario File Conversion Pipeline Works

The key components of the Impressario file conversion pipeline are

  • a database of file type rules (FTRs)

  • the wstype runtime file type recognition utility

  • the fileconvert file conversion utility

File Type Rules

The file type rules of the FTR database are documented in the Indigo Magic Desktop Integration Guide , which is available as an online book and can be installed from your IRIX CD.

The file type rules have two parts relevant to printing. The first is a TYPE rule for using the first 512 bytes of a file to recognize that the file is a particular type. The second is a CONVERT rule for converting that type to another type; the ultimate goal is to be able to convert any file type to a set of printable file types. Each CONVERT rule contains a pair of known types (a source and a destination), a Bourne shell command for converting from the source to the destination, and the computational cost of the conversion. Impressario builds on the standard IRIX database of file types by extending the FTR set to handle additional input file types, and by adding new destination file types.

Runtime File Type Recognition Utility

The wstype utility is used to determine the file type of a file or set of files. It is similar to file(1) in basic operation, but has no hardcoded special cases and no /etc/magic file, relying on the compiled FTR database for typing information.

See the wstype(1) reference page for additional information.

File Conversion Utility

The fileconvert utility builds a directed acyclic graph out of all known file types, determines the input file type, and attempts to find the lowest-cost path from source to destination. The cost analysis is necessary because the file conversion is usually a multiple-step process.

For example, suppose the goal is to print a GIF on a PostScript printer. There is no filter to directly convert a GIF to PostScript data, so fileconvert might generate a couple of alternate paths. One path is shown below:






TIFF to PostScript


A second path is shown below:








SGI to PostScript


Each of the filters has an associated computational cost. fileconvert determines the total cost of each path and chooses the lowest-cost route.

If a conversion path exists, fileconvert prints a Bourne shell command string which, when executed, generates the destination file type on standard out. Most model files simply execute this shell command string, piping the results to the printer driver. This flexible, extensible mechanism enables Impressario to print virtually any recognizable file type on any printer that is compliant with Impressario.

See the fileconvert(1) reference page for additional information.

Adding a New File Type to Impressario

To extend Impressario to make a new type of file printable, you need only perform the following steps:

  1. Write a filter to convert your new type.

  2. Write an FTR rule that recognizes the new file type.

  3. Add a CONVERT rule from that type to a known Impressario type.

  4. Install and test your changes.

Writing a New Filter

First, write a filter to convert your new type to either STIFF or PostScript, the two main formats for input to Impressario. The fileconvert utility requires that your filter be able to accept input either on standard in or from a specified filename. It should also be able to write output to standard out without using intermediate files, so that the conversion can succeed, even if the converting host has low disk space. See the Indigo Magic Desktop Integration Guide , Chapter 5, for more details. See the gif2stiff(1) reference page for an example.

Writing an FTR

Next, write an FTR that can recognize the new file type given only the first 512 bytes of the file. See the Indigo Magic Desktop Integration Guide and the ftr(1) reference page for a description of the available primitives for matching a file's type and for a description of the additional parts of a good FTR.

Adding a CONVERT Rule

As part of your FTR, add a CONVERT rule from that type to a known Impressario type. We strongly recommend that you convert image types to the STIFF93aImage type and convert other non-image file formats to the PostScriptFile type. Refer to Appendix A and the libstiff(3) reference page for information on writing STIFF output. Note that once you convert to either a PostScriptFile or a STIFF93aImage, Impressario knows how to convert that file type to a printable format on any printer.

Model files that are compliant with Impressario also automatically set the proper environment variables for the options the user selected on the spooler command line, and the standard Impressario CONVERT rules automatically pick up the appropriate environment variables when converting these file types to printable types. This is how user-specified printing options are applied to the dynamically-constructed file conversion pipeline.

Installation and Testing

The easiest way to show how to test a new file type is by example.

Setting Up an Example

The example makes the following assumptions:

  • The new file type is called BlastFile.

  • The new FTR is in the directory /usr/tmp/

  • A sample BlastFile is in the directory /usr/tmp/sample.blastfile.

  • All BlastFiles start with the word blastfile.

A sample (although incomplete) TYPE rule for the example would look like this:

TYPE BlastFile
    MATCH string(0,9) == "blastfile";
    LEGEND Blast Image File

CONVERT BlastFile STIFF93aImage
    COST 50
    FILTER /usr/lib/print/blast2stiff $IMPR_IMG2STIFFOPTS

Testing the New File Type

  1. To test the new file type, become root by entering:


    Supplying a password, if necessary.

  2. Copy your FTR into /usr/lib/filetype/install:

    cp /usr/tmp/ /usr/lib/filetype/install

  3. Compile the FTR database:

    cd /usr/lib/filetype ; make

    See the ftr(1) reference page if any errors occur.

  4. Run wstype to verify that Impressario now recognizes your file type:

    wstype /usr/tmp/sample.blastfile

    You should see the following output:

    /usr/tmp/sample.blastfile BlastFile

  5. Try to convert that file type to a printable file type. The most printable file type in the Impressario database is ImpressarioPostScriptFile, so try that:

    fileconvert -d ImpressarioPostScriptFile \

    You should get back something like:

    PRINTFILES=”/usr/tmp/sample.blastfile” ; /usr/lib/print/blast2stiff $IMPR_IMG2STIFFOPTS $PRINTFILES | /usr/lib/print/stiff2ps $IMPR_SGI2PSOPTS

    Note: The above output appears on one line.

    If fileconvert does not return a valid shell command string, check the exit code of the filter. If you are in the C shell, enter:

    echo $status

    If you are in the Bourne shell, enter:

    echo $?

    If the exit code is not zero, then fileconvert was unable to convert your file type. Verify that your destination file type is convertible to a printable type by checking the CONVERT rules in the FTR database and making sure there is a conversion path from your destination type to the Impressario type, then try the above steps again.

  6. Once steps 1-5 work, verify that your filter produces valid output by entering

    vstiff /usr/tmp/sample.blastfile

    This should bring up the vstiff previewer, which uses the FTR database of TYPE and CONVERT rules to convert to a screen-viewable STIFF file. Use the “PostScript Options...” menu choice on the File menu to choose different color spaces and depths. See the vstiff(1) reference page for more help.

    Note: If your filter converts directly to STIFF93aImage, the PostScript options in vstiff are not applicable.

  7. Finally, try printing that file to an Impressario printer. Enter:

    lp -dprintername /usr/tmp/sample.blastfile

    Watch the spooler log file for errors and the printstatus panel for printer messages until the file prints. If you were able to vstiff the file, then you should to be able to print it.

When you have completed this process, you should have the files shown in Table 11-1. These files should be installed with the permissions and the ownerships shown and at the locations shown. The actual file basename may change but the pathname should not. Conversion filters should be installed in /usr/lib/print.

Table 11-1. New File Type Pathnames




Full Pathname









Using an Alternate PostScript RIP

Using an alternate PostScript Raster Image Processor (RIP) is extremely easy in the Impressario open architecture. You can even switch RIPs at the last possible moment without losing any of the features of the Impressario file conversion pipeline.

The steps required to add an alternate RIP to your system are as follows:

  1. Make the new RIP command line compatible with the Impressario RIP, psrip.

  2. Write a dummy TYPE.

  3. Test the alternative RIP.

  4. Package the files.

You should be able to use this alternate RIP instead of the Impressario interpreter, which is no longer shipped or supported.

Note: In the example below, the new RIP is called blastrip and is installed in the directory /usr/lib/print.

Making the Command Line Compatible With psrip

Your new RIP must be command-line compatible with psrip. For more information on what this means, see Appendix I, “PostScript Interpreter (psrip) Command Line Options.”psrip accepts ASCII and binary PostScript either on standard in or in a disk file, and generates a variety of sizes, colorspaces, and depths of STIFF bitmaps on standard out.

Being command-line compatible with psrip is probably the most tedious part of adding a new interpreter, but is well worth the effort when you consider that you gain all the advantages of Impressario:

  • plug-and-play printer drivers

  • automatic file type recognition

  • automatic file type conversion

Writing a Dummy TYPE

The next step is to write a dummy TYPE and a simple CONVERT rule. First create a new, empty TYPE definition for your output raster format. For example:

TYPE BlastRasterBitmap
# dummy type for use in model file only
    MATCH false;

CONVERT ImpressarioPostScriptFile BlastRasterBitmap
# convert from formatted, filtered ImpressarioPostScriptFile
# to a RIPped bitmap
    COST   50
    FILTER /usr/lib/print/blastrip $IMPR_PSRIPOPTS

Install that file in /usr/lib/filetype/install/ and compile your FTR database by entering

su ; cd /usr/lib/filetype ; make

Now test the conversion and preview the bitmap by using vstiff:

fileconvert -d BlastRasterBitmap /etc/passwd | vstiff -stdin

If you run into problems viewing it, then save it to disk and use other tools to verify that you have a valid STIFF file. However, if vstiff cannot view it, then Impressario printer drivers will probably not be able to print it.

Testing the Alternate RIP

To use the alternative RIP in your printer model files instead of the default psrip, change all references to “ImpressarioRasterBitmap” to “BlastRasterBitmap.” The lines below were taken from the laserjetPJL_model template model file and the word ImpressarioRasterBitmap was changed to BlastRasterBitmap:

# Use fileconvert to convert to the printer's native format.
# For raster printers, it is BlastRasterBitmap.
# For PostScript printers, it is ImpressarioPostScriptFile.
CMD=`$fileconvert $fileconvertopts -d BlastRasterBitmap $file 2> /dev/null`

Packaging the Files

You are finished now, and need only package these optional RIP files for installation. The files you should be installing may have different names, but should be installed in the following directories, with the permissions and ownerships shown in Table 11-2.

Table 11-2. Alternative RIP Pathnames




Full Pathname









You should modify your printer's model file to use the new RIP whenever you want. You can, of course, still ask for ImpressarioRasterBitmap.

Note: Test carefully to make sure that your new RIP is, in fact, compatible with the existing psrip before shipping your product.