[Status] [Installation] [Usage] [Known bugs] [Versions] [Copyright] [Download]

[see below for a comment on the status of this code.]

Patch to xv-3.10a: xv-psnewstyle

The xv-psnewstyle patch provides a different Postscript output format, which is more compact and is rendered faster on most printers. An option in the Postscript save dialogue allows a standard xv Postscript file to be output to allow comparison of the two formats.

The xv-psnewstyle Postscript output uses the Lempel-Ziv Welch (LZW) compression algorithm for image encoding in Postscript. This produces very compact files: usually several times smaller than files produced with Run Length Encoding (which is used in xv's standard compressed Postscript output) and very much smaller than files produced without compression.

Unlike the standard xv, xv-psnewstyle also allows compression of 24-bit images, though LZW compression may not be effective on 24-bit colour photographic images - in which case a slightly larger file could even be produced (in this case, compression need not be enabled in the Postscript save dialogue).

Additional compression is obtained by using an 85-letter character encoding (! to u), rather than hexadecimal. This gives a size reduction of a factor 1.6 (excluding header information). % characters in the first column are indented by one character to prevent programs that strip Postscript comments (eg. dvips without the -K0 option) from removing these lines.

Postscript files produced by xv-psnewstyle automatically understand on what kind of printer they are being printed. On Level 2 Postscript printers the native LZW/ASCII85 decoding filters will be invoked, while on Level 1 printers inline decompression code is executed. Rendering time on Level 2 printers is pretty fast. On Level 1 printers the image rendering is, of course, much slower, but still usually faster than for Run Length Encoded Postscript images.

The xv-psnewstyle patch was written by Tim Adye <T.J.Adye@rl.ac.uk>, using C and Postscript code based originally on the Postscript generation code in xwpick 2.21 by Evgeni Chernyaev <chernaev@mx.ihep.su> (xwpick used to be called xpick). Some of this code was also used in the gifconv program. I have modified the xwpick C and Postscript code extensively, so any bugs therein are almost certainly my fault.


This patch still has a few sharp edges (see below), could do with a lot of tidying up, checking, and more careful comparison with standard xv (there are a few features of the standard xv's Postscript output that should also be available in the xv-psnewstyle). But it basically works for what I want it to do, so I've decided to pause at this point and make it available in case anyone else finds it useful.

If there is much interest, I'll try to do a better job of tidying it up and making it more generally applicable. I also have a few ideas on further improvements. So, if you think this might be of interest to you, let me know (email T.J.Adye@rl.ac.uk).


All required files are included in this patch file. Copy the patch file into your xv-3.10a/ source directory and run

patch < xv-psnewstyle.patch
Then recompile with make as usual.


xv-3.10a patched with xv-psnewstyle looks very similar to the standard xv.

In the Postscript save dialogue, there is a new checkbox "new style". When selected (the default), xv-psnewstyle is used. When deselected, the standard xv Postscript output is used (in this case, the "compress" option will become inactive for 24-bit images, since standard xv does not support compressed 24-bit images).

With "new style" enabled, the "compress" checkbox enables and disables LZW compression. ASCI85 encoding is used in both cases.

Known Bugs

Version Information

24 Jan 97, version 0.1
Initial version for gifconv program, based on Evgeni Chernyaev's xwpick 2.21. Also includes some minor improvements to xwpick 2.21 (making 2.21a), removing the hardcoded limit (4096) on the width of the image and adding the size parameters.
22 May 98, version 0.2
Much tidying up, including some const-correctness.
19 Jul 99, version 0.4
Renamed PS_LZWencode routine to psencode. First version for xv-psnewstyle. Added noLZW option. Added 24-bit direct colour and direct grayscale output.

LZW Licensing Issues

The LZW encoding routines were written in 1993/4 by Evgeni Chernyaev as part of Xwpick. Since then Unisys have asserted a patent on the LZW algorithm. Use of xv-psnewstyle may be constrained by this patent.

Copyright Notice

xv-psnewstyle is Copyright 1994, 1996, 1998, 1999 by Tim Adye <T.J.Adye@rl.ac.uk>. The following copyright restrictions and disclaimer apply also to the xv-psnewstyle code.

Xwpick is Copyright 1993, 1994 by Evgeni Chernyaev

Permission to use, copy, modify, and distribute this software and its documentation for non-commercial purpose is hereby granted without fee, provided that the above copyright notice appear in all copies and that both the copyright notice and this permission notice appear in supporting documentation.

This software is provided "as is" without express or implied warranty.

The xwpick author may be contacted via:

Evgeni Chernyaev
Institute for High Energy Physics
142284 Protvino, Moscow region

HTML 3.2 Checked... Best viewed with ANY browser! http://hepwww.rl.ac.uk/Delphi/Adye/xv-psnewstyle.html last modified 20th July 1999 by
Tim Adye, <T.J.Adye@rl.ac.uk>