VTeX/GeX image plugins


Beginning with version 6.4, VTeX/GeX supports image filtering plugins.

Image filtering plugins allow one to manupulate the document images during the run time. One can use image plugins to fine-tune the image appearance, or to reduce its size, or to do anything else you may like to it---since GeX API is open, your imagination is the limit.

To see what image filtering plugins can deliver, you may want to preview the supplied sample. For explanation and technical details, read on.

image operator in GeX

Image plugins are made possible by 2-part implementation of the PostScript image operator. GeX breaks it into two internal operators: .loadimage and .produceimage. Here .loadimage is responsible for gathering the image data in memory; .produceimage emits the data into the document (for example, a .pdf file) that is being constructed.

If one redefines (for example, with \special{pS:...})

/image {.loadimage .produceimage} def

Then the image operator will function as usual; however, between the .loadimage and .produceimage, the image data would be fully accessible to a GeX plugin.

For example, assuming that ToGray is a plugin that implements a new GeX operator "toGray". We can now try

\special{pS: (ToGray) .extend} % Add plugin to the GeX environment, this makes toGray known \special{pS: save} % To forget /image redefinition later. \special{pS: /image (.loadimage toGray .produceimage}def} .... \includegraphics{test.eps} % Include an .eps file that contains an image; it will be transformed to grayscale <br>.... \special{pS: restore} % Restore the original definition

non-PostScript images

The technique described above will work on images that had been converted to .eps files. However, the majority of images you may want to filter would likely be supplied in a bitmapped format (VTeX currently supports BMP, PCX, GIF, JPEG, TARGA, TIFF, and PNG). To simplify the use of these formats, GeX has another extension operator, .readimage.

The .readimage operator accept a single string argument which is the name of bitmapped file; it returns a GeX-compatible image structure which can be either given directly to .produceimage or processed through a plugin filter. For example,

\special{pS: (mypic.gif) .readimage toGray .produceimage}

will read a GIF image, convert it to grayscale, and then output it. Notice that in addition to filtering, this operator has other applications; one would be using bitmapped icons within a PStricks environment.

Graphicx support

While the low-level details provided above may look scary, using image filters is actually very easy. The low-level functionality has been integrated into the graphicx package, and all you need to know are just a few of extra options. Some new keywords are:
viagex Process a bitmapped image via GeX; this key is required for any image filtering.
brightness=B Make image brighter (B>0) or darker (B<0)
contrast=C Make image more (C>0) or less (C<0) contrast
colorspace=S Convert image to another color space (for example, make it grayscaled)
degrade=D Downsample the image (usually, to