home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: Graphics / Graphics.zip / jpeg2ps2.zip / jpeg2ps.txt < prev    next >
Text File  |  1997-01-23  |  10KB  |  231 lines

  1. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  2. jpeg2ps - convert JPEG compressed images to PostScript Level 2
  3.  
  4. jpeg2ps is available from http://www.muc.de/~tm
  5.  
  6. Copyright (C) 1994-96 Thomas Merz (tm@muc.de)
  7. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  8.  
  9. Purpose of jpeg2ps
  10. ==================
  11. jpeg2ps converts JPEG files to PostScript level 2 EPS. In fact, jpeg2ps
  12. is not really a converter but a "wrapper": it reads the image parameters
  13. (width, height, number of color components) in a JPEG file, writes the
  14. according EPS header and then copies the compressed JPEG data to the output
  15. file. Decompression is done by the PostScript interpreter (only PostScript
  16. level 2 interpreters support JPEG compression and decompression). If you
  17. have a slow communication channel and a fast printer, sending compressed
  18. image data is a big win.
  19.  
  20.  
  21. Change History
  22. ==============
  23. V1.0 (Jan. 9, 1996) Re-release of formerly released Usenet version.
  24.  
  25. V1.1 (Jan. 22, 1996) Several enhancements:
  26.   - invert colors of Adobe Photoshop CMYK files
  27.   - interpret JFIF resolution ("density") markers
  28.   - implemented -r switch for specifying resolution 
  29.   - accept compression markers other than SOF0 and SOF1 (this won't
  30.     be useful for many people, and didn't have any testing).
  31.  
  32. V1.2 (Jan. 25, 1996) 
  33.   - Fixed "unsigned" bug when reading JFIF density marker.
  34.  
  35. V1.3 (Jan. 31, 1996)
  36.   - Fixed ASCII85 encoding bug. In rare cases ~ and > could get
  37.     separated.
  38.  
  39. V1.4 (Aug. 19, 1996)
  40.   - included getopt.c in distribution, changed option handling
  41.   - prepared readjpeg.c for use with jpeg2pdf program (accept baseline only)
  42.   - included jpeg2pdf in the distribution
  43.  
  44. V1.5 (Dec. 12, 1996)
  45.   - Included ASCIIHex encoding again (the code was already there,
  46.     only command line option added). This is primarily useful as as
  47.     workaround for a brain-damaged dvips "feature" (see below).
  48.   - Added note on dvips and tgif in jpeg2ps.txt.
  49.   - Removed jpeg2pdf again. Its functionality will be contained in the
  50.     forthcoming PDFLIB C library and some library client programs.
  51.  
  52.  
  53. Source Code and Executable
  54. ==========================
  55. jpeg2ps is coded in rather simple-minded C. It should compile cleanly
  56. on MS-DOS, UNIX and other systems. For old K&R compilers, include the
  57. compiler flag -DKNR in the makefile to disable ANSI prototypes.
  58.  
  59. The jpeg2ps distribution is available in .zip and .tar.gz format.
  60. jpeg2ps.zip is intended for MS-DOS and also includes an executable.
  61. Source code is identical in both jpeg2ps.zip and jpeg2ps.tar.gz, the only
  62. exception being different line end conventions.
  63.  
  64.  
  65. Usage Details
  66. =============
  67. jpeg2ps [-b] [-h] [-r dpi] file.jpg > file.eps
  68.  
  69. -b       binary mode
  70. -h       hex mode (ASCIIHex encoding)
  71. -r dpi   resolution value (0 = read from file if possible)
  72.  
  73. jpeg2ps reads a JPEG file (*not* stdin) and writes a DSC-compliant EPS
  74. file containing the compressed JPEG data in PostScript format to stdout.
  75. The produced EPS files contain the necessary DSC comments including 
  76. BoundingBox, so they may be imported in page layout applications. However,
  77. they do not contain preview images, so you will only see a gray box onscreen.
  78.  
  79. jpeg2ps performs some sanity checks with the JPEG data. It detects several
  80. kinds of corrupt input data, but it is not absolutely foolproof. One special
  81. feature is that you can feed Macintosh JPEG files (PICT-JPEG) to jpeg2ps. 
  82. These normally have several hundred bytes of additional bytes before the JPEG 
  83. data. This PICT rubbish is simply ignored by jpeg2ps.
  84.  
  85.  
  86. Output modes
  87. ============
  88. By default, jpeg2ps sends the image data in ASCII85 encoded form which is
  89. suitable for any communication channel (serial, parallel or whatever). If
  90. you are *sure* that your channel is truly 8-bit clean, you can force 8-bit
  91. data with the -b option. Note that this normally does not apply to 8-bit
  92. serial or even parallel channels since some control characters are reserved
  93. for the communications protocol. You can use binary data e.g.:
  94.  
  95. - with some networked printers
  96. - with direct-access PostScript interpreters, e.g. Ghostscript
  97. - serial or parallel channels using Binary Control Protocol (BCP).
  98.  
  99. Using the -h option, jpeg2ps generates 7-bit clean data by using
  100. ASCIIHex encoding instead of the more space-efficient ASCII85 encoding.
  101.  
  102.  
  103. Scaling and resolution
  104. ======================
  105. Concerning the size of the printed image, you have three options:
  106.  
  107. Default behaviour:
  108. By default, jpeg2ps tries to fit the image on the page, rotating it
  109. if necessary (image width exceeds image height). The image is scaled
  110. in a way to use at least one full edge of the paper. A 20 pt margin
  111. is subtracted on each side. "Page" means A4 size if compiled with 
  112. "-DA4", letter size otherwise.
  113.  
  114. Using resolution value from the file:
  115. The option "-r 0" instructs jpeg2ps to look for a JFIF density/resolution
  116. marker and use that value. Automatic scaling and rotation are disabled.
  117. However, if no resolution information is found in the file, jpeg2ps
  118. applies the default algorithm described above.
  119.  
  120. Explicitly setting the resolution:
  121. Using "-r <dpi>" you can force jpeg2ps to use a certain dpi value. 
  122. Since automatic actions are also disabled in this case, you are 
  123. responsible for choosing a reasonable resolution value.  For example, 
  124. you can print a 300 dpi image half-sized by supplying -r 600.
  125.  
  126.  
  127. Messages
  128. ========
  129. jpeg2ps issues three kinds of messages:
  130.  
  131. Notes:    have informational character
  132.  
  133. Warnings: a potential problem with the file was recognized, processing
  134.       continues.
  135.  
  136. Errors:   Either a severe problem within the JPEG file was found or the
  137.           file explores JPEG features not compatible with PostScript Level 2.
  138.  
  139. Note that there are some JPEG producers which do not exactly conform to the
  140. specification and that the JPEG spec itself does not cover every aspect of
  141. the file format. You are on the safe side if you demand JFIF files which are
  142. happily accepted by jpeg2ps. (For further information see the JPEG FAQ
  143. by Tom Lane.)
  144.  
  145.  
  146. Adobe Photoshop CMYK files
  147. ==========================
  148. This is what the Independent JPEG Group has to say about Photoshop
  149. CMYK files (quoted from libjpeg.doc, part of the IJG JPEG library):
  150.  
  151. > CAUTION: it appears that Adobe Photoshop writes inverted data in CMYK JPEG
  152. > files: 0 represents 100% ink coverage, rather than 0% ink as you'd expect.
  153. > This is arguably a bug in Photoshop, but if you need to work with Photoshop
  154. > CMYK files, you will have to deal with it in your application.  We cannot
  155. > "fix" this in the library by inverting the data during the CMYK<=>YCCK
  156. > transform, because that would break other applications, notably Ghostscript.
  157. > Photoshop versions prior to 3.0 write EPS files containing JPEG-encoded CMYK
  158. > data in the same inverted-YCCK representation used in bare JPEG files, but
  159. > the surrounding PostScript code performs an inversion using the PS image
  160. > operator.  I am told that Photoshop 3.0 will write uninverted YCCK in
  161. > EPS/JPEG files, and will omit the PS-level inversion.  (But the data
  162. > polarity used in bare JPEG files will not change in 3.0.)  In either case,
  163. > the JPEG library must not invert the data itself, or else Ghostscript would
  164. > read these EPS files incorrectly.
  165.  
  166. Accordingly, jpeg2ps tries to detect such files (by looking for Adobes
  167. APP marker) and inverts the colors in the case of 4-component images.
  168. This inversion takes place in the PostScript file, not by changing the
  169. image data.
  170.  
  171.  
  172. Note to TeX and tgif users
  173. ==========================
  174. It seems that dvips strips all lines beginning with "%%" from embedded
  175. EPS files. Since you can't cheat on Murphy, such lines actually appear
  176. in the ASCII85 encoded data section of real world images! The stripping
  177. "feature" renders such files useless -- a PostScript error will occur.
  178. Short of adapting the jpeg2ps output to this behaviour, I added support
  179. for ASCIIHex encoding in jpeg2ps. Therefore:
  180.  
  181. Use the -h option if you intend to use the EPS with dvips!
  182.  
  183. Alternatively, a dvips user reported the following:
  184.  
  185. > I recall that in the very recent release
  186. > of dvips 5.62, the readme states that comments are not removed by default
  187. > anymore. There has long been a command line switch -K0 to turn off comment
  188. > stripping. I just tried this and it works.
  189.  
  190. Since I don't use TeX and dvips I cannot further comment on this. I
  191. simply wanted jpeg2ps users to be aware of the problem and possible
  192. workarounds.
  193.  
  194. Reportedly, the tgif vector drawing program also strips lines beginning
  195. with a % character. Use the -h option or - better yet - ask the author
  196. of the software to fix this bug!
  197.  
  198.  
  199. Further Information
  200. ===================
  201.  
  202. If you like to know more about the inner workings of jpeg2ps, the JPEG
  203. standard and its integration in PostScript Level 2, the JFIF file format,
  204. JPEG/TIFF *and* if you can read German, you may want to check out 
  205. my article in a German computer magazine:
  206.  
  207. "Gut verpackt - Drucken von JPEG-Bildern mit PostScript Level 2"
  208. c't, Magazin fuer Computertechnik, Heise Verlag Hannover, 6/94, p.236 ff.
  209.  
  210. This article is also available in PDF format from my WWW page:
  211. http://www.muc.de/~tm
  212.  
  213. Note that there is a related PostScript programm called "viewjpeg.ps" which
  214. is part of the Ghostscript distribution. viewjpeg.ps operates similar to
  215. jpeg2ps, but the PostScript interpreter does the "wrapping" of JPEG data
  216. itself. With viewjpeg.ps you can e.g. view JPEG files directly within 
  217. GhostScript or another interpreter with access to the file system.
  218.  
  219.  
  220. Disclaimer 
  221. ==========
  222. This software is free. You are granted the right to use and copy it. This
  223. software may not be sold or bundled with any commercial package without
  224. express written permission of the author. 
  225.  
  226. The author accepts no responsibility for damages resulting from the use of
  227. this software and makes no warranty, either express or implied, including but
  228. not limited to, any implied warranty of merchantability or fitness for a
  229. particular purpose. This software is provided as is, and you assume all risks
  230. when using it. 
  231.