=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- jpeg2ps - convert JPEG compressed images to PostScript Level 2 jpeg2ps is available from http://www.muc.de/~tm Copyright (C) 1994-96 Thomas Merz (tm@muc.de) =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- Purpose of jpeg2ps ================== jpeg2ps converts JPEG files to PostScript level 2 EPS. In fact, jpeg2ps is not really a converter but a "wrapper": it reads the image parameters (width, height, number of color components) in a JPEG file, writes the according EPS header and then copies the compressed JPEG data to the output file. Decompression is done by the PostScript interpreter (only PostScript level 2 interpreters support JPEG compression and decompression). If you have a slow communication channel and a fast printer, sending compressed image data is a big win. Change History ============== V1.0 (Jan. 9, 1996) Re-release of formerly released Usenet version. V1.1 (Jan. 22, 1996) Several enhancements: - invert colors of Adobe Photoshop CMYK files - interpret JFIF resolution ("density") markers - implemented -r switch for specifying resolution - accept compression markers other than SOF0 and SOF1 (this won't be useful for many people, and didn't have any testing). V1.2 (Jan. 25, 1996) - Fixed "unsigned" bug when reading JFIF density marker. V1.3 (Jan. 31, 1996) - Fixed ASCII85 encoding bug. In rare cases ~ and > could get separated. V1.4 (Aug. 19, 1996) - included getopt.c in distribution, changed option handling - prepared readjpeg.c for use with jpeg2pdf program (accept baseline only) - included jpeg2pdf in the distribution V1.5 (Dec. 12, 1996) - Included ASCIIHex encoding again (the code was already there, only command line option added). This is primarily useful as as workaround for a brain-damaged dvips "feature" (see below). - Added note on dvips and tgif in jpeg2ps.txt. - Removed jpeg2pdf again. Its functionality will be contained in the forthcoming PDFLIB C library and some library client programs. Source Code and Executable ========================== jpeg2ps is coded in rather simple-minded C. It should compile cleanly on MS-DOS, UNIX and other systems. For old K&R compilers, include the compiler flag -DKNR in the makefile to disable ANSI prototypes. The jpeg2ps distribution is available in .zip and .tar.gz format. jpeg2ps.zip is intended for MS-DOS and also includes an executable. Source code is identical in both jpeg2ps.zip and jpeg2ps.tar.gz, the only exception being different line end conventions. Usage Details ============= jpeg2ps [-b] [-h] [-r dpi] file.jpg > file.eps -b binary mode -h hex mode (ASCIIHex encoding) -r dpi resolution value (0 = read from file if possible) jpeg2ps reads a JPEG file (*not* stdin) and writes a DSC-compliant EPS file containing the compressed JPEG data in PostScript format to stdout. The produced EPS files contain the necessary DSC comments including BoundingBox, so they may be imported in page layout applications. However, they do not contain preview images, so you will only see a gray box onscreen. jpeg2ps performs some sanity checks with the JPEG data. It detects several kinds of corrupt input data, but it is not absolutely foolproof. One special feature is that you can feed Macintosh JPEG files (PICT-JPEG) to jpeg2ps. These normally have several hundred bytes of additional bytes before the JPEG data. This PICT rubbish is simply ignored by jpeg2ps. Output modes ============ By default, jpeg2ps sends the image data in ASCII85 encoded form which is suitable for any communication channel (serial, parallel or whatever). If you are *sure* that your channel is truly 8-bit clean, you can force 8-bit data with the -b option. Note that this normally does not apply to 8-bit serial or even parallel channels since some control characters are reserved for the communications protocol. You can use binary data e.g.: - with some networked printers - with direct-access PostScript interpreters, e.g. Ghostscript - serial or parallel channels using Binary Control Protocol (BCP). Using the -h option, jpeg2ps generates 7-bit clean data by using ASCIIHex encoding instead of the more space-efficient ASCII85 encoding. Scaling and resolution ====================== Concerning the size of the printed image, you have three options: Default behaviour: By default, jpeg2ps tries to fit the image on the page, rotating it if necessary (image width exceeds image height). The image is scaled in a way to use at least one full edge of the paper. A 20 pt margin is subtracted on each side. "Page" means A4 size if compiled with "-DA4", letter size otherwise. Using resolution value from the file: The option "-r 0" instructs jpeg2ps to look for a JFIF density/resolution marker and use that value. Automatic scaling and rotation are disabled. However, if no resolution information is found in the file, jpeg2ps applies the default algorithm described above. Explicitly setting the resolution: Using "-r " you can force jpeg2ps to use a certain dpi value. Since automatic actions are also disabled in this case, you are responsible for choosing a reasonable resolution value. For example, you can print a 300 dpi image half-sized by supplying -r 600. Messages ======== jpeg2ps issues three kinds of messages: Notes: have informational character Warnings: a potential problem with the file was recognized, processing continues. Errors: Either a severe problem within the JPEG file was found or the file explores JPEG features not compatible with PostScript Level 2. Note that there are some JPEG producers which do not exactly conform to the specification and that the JPEG spec itself does not cover every aspect of the file format. You are on the safe side if you demand JFIF files which are happily accepted by jpeg2ps. (For further information see the JPEG FAQ by Tom Lane.) Adobe Photoshop CMYK files ========================== This is what the Independent JPEG Group has to say about Photoshop CMYK files (quoted from libjpeg.doc, part of the IJG JPEG library): > CAUTION: it appears that Adobe Photoshop writes inverted data in CMYK JPEG > files: 0 represents 100% ink coverage, rather than 0% ink as you'd expect. > This is arguably a bug in Photoshop, but if you need to work with Photoshop > CMYK files, you will have to deal with it in your application. We cannot > "fix" this in the library by inverting the data during the CMYK<=>YCCK > transform, because that would break other applications, notably Ghostscript. > Photoshop versions prior to 3.0 write EPS files containing JPEG-encoded CMYK > data in the same inverted-YCCK representation used in bare JPEG files, but > the surrounding PostScript code performs an inversion using the PS image > operator. I am told that Photoshop 3.0 will write uninverted YCCK in > EPS/JPEG files, and will omit the PS-level inversion. (But the data > polarity used in bare JPEG files will not change in 3.0.) In either case, > the JPEG library must not invert the data itself, or else Ghostscript would > read these EPS files incorrectly. Accordingly, jpeg2ps tries to detect such files (by looking for Adobes APP marker) and inverts the colors in the case of 4-component images. This inversion takes place in the PostScript file, not by changing the image data. Note to TeX and tgif users ========================== It seems that dvips strips all lines beginning with "%%" from embedded EPS files. Since you can't cheat on Murphy, such lines actually appear in the ASCII85 encoded data section of real world images! The stripping "feature" renders such files useless -- a PostScript error will occur. Short of adapting the jpeg2ps output to this behaviour, I added support for ASCIIHex encoding in jpeg2ps. Therefore: Use the -h option if you intend to use the EPS with dvips! Alternatively, a dvips user reported the following: > I recall that in the very recent release > of dvips 5.62, the readme states that comments are not removed by default > anymore. There has long been a command line switch -K0 to turn off comment > stripping. I just tried this and it works. Since I don't use TeX and dvips I cannot further comment on this. I simply wanted jpeg2ps users to be aware of the problem and possible workarounds. Reportedly, the tgif vector drawing program also strips lines beginning with a % character. Use the -h option or - better yet - ask the author of the software to fix this bug! Further Information =================== If you like to know more about the inner workings of jpeg2ps, the JPEG standard and its integration in PostScript Level 2, the JFIF file format, JPEG/TIFF *and* if you can read German, you may want to check out my article in a German computer magazine: "Gut verpackt - Drucken von JPEG-Bildern mit PostScript Level 2" c't, Magazin fuer Computertechnik, Heise Verlag Hannover, 6/94, p.236 ff. This article is also available in PDF format from my WWW page: http://www.muc.de/~tm Note that there is a related PostScript programm called "viewjpeg.ps" which is part of the Ghostscript distribution. viewjpeg.ps operates similar to jpeg2ps, but the PostScript interpreter does the "wrapping" of JPEG data itself. With viewjpeg.ps you can e.g. view JPEG files directly within GhostScript or another interpreter with access to the file system. Disclaimer ========== This software is free. You are granted the right to use and copy it. This software may not be sold or bundled with any commercial package without express written permission of the author. The author accepts no responsibility for damages resulting from the use of this software and makes no warranty, either express or implied, including but not limited to, any implied warranty of merchantability or fitness for a particular purpose. This software is provided as is, and you assume all risks when using it.