Ticket #39382: sam2p---README.txt

File sam2p---README.txt, 126.0 KB (added by KurtPfeifle (Kurt Pfeifle), 11 years ago)

README as found on code.google.com

Line 
1README for sam2p
2by pts@fazekas.hu
3at Sun Dec 30 19:30:17 CET 2001 -- Fri Mar 22 19:25:03 CET 2002
4Sat Apr 27 00:39:12 CEST 2002
5Wed Jul  3 01:20:40 CEST 2002
6Wed Feb  5 19:46:51 CET 2003
7grammatical corrections by Steve Turner at Mon Jan 10 00:53:46 CET 2005
8
9This is the README file for sam2p, a raster to PostScript/PDF image
10conversion program. This file contains a 5-minute turbo tutorial for new and
11impatient users (search for the phrase `Turbo tutorial' in your text editor).
12As of now, this README file is the only, and definitive, documentation of sam2p.
13
14sam2p is a UNIX command line utility written in ANSI C++ that converts many
15raster (bitmap) image formats into Adobe PostScript or PDF files and several
16other formats. The images are not vectorized. sam2p gives full control to
17the user to specify standards-compliance, compression, and bit depths. In
18some cases sam2p can compress an image 100 times smaller than the PostScript
19output of many other common image converters. sam2p provides ZIP, RLE and
20LZW (de)compression filters even on Level1 PostScript devices.
21
22A testimonial from Grant Ingram, UK: Anyway this is just a quick note to say
23thanks for writing the sam2p utility which I am using to create EPS figures
24of photographs for my thesis -- it works very well producing image sizes
25that are some 3% of the ones produced by ImageMagick.
26
27Does sam2p generate small EPS (and PDF) files?
28A testimonial from Tom Schneider, US:
29
30  -rw-------   1 toms     delila     88628 Mar  3 17:38 prototype-small.eps
31  -rw-------   1 toms     delila   7979299 Feb 24 12:25 prototype.eps
32 
33  Good GRIEF you have written a nice program!!!!  The file is 90 fold
34  smaller than the one from Imagemagick's convert.
35
36  That image that was 90x smaller had been bugging me because it was so
37  large that xdvi would strongly hesitate while I passed by the page.
38  Now it just has a minor delay, thanks to you.
39
40Many thanks to Steve Turner for reviewing and making corrections to this
41documentation.
42
43The author of sam2p recommends his program over other image converters
44because of the following reasons:
45
46-- sam2p produces much smaller output
47-- sam2p gives the user complete control over the data layout of the output
48   image. This includes Compression, SampleFormat and TransferEncoding.
49-- sam2p is fast
50-- sam2p doesn't depend on external libraries. (But it does depend on external
51   programs for _reading_ JPEG, TIFF and PNG files.)
52-- sam2p supports the mainstream image formats of today without compromise.
53   sam2p has many file format fine-tuning features that are missing from
54   most other converter utilities. For example:
55   TIFF ZIP compression, TIFF LZW compression, TIFF
56   JPEG compression, transparent PNG files, BMP RLE-4 and RLE-8
57   compression, etc.
58-- sam2p supports all levels (versions) of the PostScript language and
59   output images have the smallest file size allowed by the LanguageLevel.
60-- PostScript ZIP, RLE and LZW compression is provided for _all_
61   LanguageLevels (!), even for PSL1 (which appeared in 1980). You can print
62   your ZIP-compressed images onto your ancient printer of the 1980s.
63-- sam2p supports all versions of PDF, and as with PostScript,
64   output images have the smallest file size allowed by the version.
65-- output images of sam2p are always compliant to the standard selected by
66   the user
67-- output images of sam2p are real-world compatible, i.e the author has
68   tested them with many common image processing programs, for example:
69   Ghostscript, pdfTeX, xpdf, Acrobat Reader, The GIMP, ImageMagick, xv,
70   Acrobat Distiller, QuarkXPress, InDesign. The author has also tested
71   PostScript files on HP and OkiData printers.
72-- sam2p converts every pixel faithfully, preserving all the 24 RGB bits
73   intact. There is no quality or information loss unless you ask for it.
74-- sam2p uses only a minimal number of libraries. You don't have to install
75   33Mb of ballast software to use sam2p. Image libraries (libtiff etc.) are
76   _not_ used, the math library is not used, libstdc++ is not used, zlib is
77   not used.
78
79Long-term limitations:
80
81-- only DeviceRGB color space, with the Indexed, Gray and RGB image types
82-- Indexed images are limited to a maximum of 256 colors
83-- alpha channel and transparency supported only for Indexed images: only
84   one color may be transparent
85-- the entire input image is read into memory. During operation both the
86   input and the output images may be held in memory.
87 
88Status
89~~~~~~
90sam2p is currently beta software. It is available from:
91
92        http://www.inf.bme.hu/~pts/sam2p/
93        http://www.inf.bme.hu/~pts/sam2p-latest.tar.gz
94        http://sam2p.sf.net/
95
96The documentation is incomplete, but -- together with the examples -- it is
97quite useful. Please have a look at the home page to find articles and more
98documentation (the PDF docs are much more eye-pleasing than this README).
99The source code contains valuable comments, but they may be hard to find
100unless you're deeply into developing sam2p.
101
102The author is developing sam2p in his free time. (He is studying and
103working in non-free time.)
104
105The imaging model is complete. Image output routines are stable and
106adequate. Reasonable defaults are provided for all command line options.
107sam2p can usually find the best SampleFormat automatically. There is
108an educated (but not perfect) default guess for the Compression.
109
110See subsection {OutputRule combinations} about all planned formats.
111
112The most important short-term limitations:
113
114-- The code hasn't been extensively tested. The author welcomes bug reports.
115-- The code hasn't been profiled for speed bottlenecks. (Although it seems
116   to be faster than ImageMagick convert(1) in most situations.)
117
118Turbo tutorial
119~~~~~~~~~~~~~~
120Quick compilation instructions:
121
1221. ./configure --enable-lzw --enable-gif
1232. make
1243. Copy the `sam2p' executable to your $PATH, or invoke it as `./sam2p'.
125
126Quick try:
127
128-- ./sam2p examples/pts2.pbm try.eps
129-- ./sam2p examples/pts2.pbm try.pdf
130-- ./sam2p examples/pts2.pbm try.ps
131-- ./sam2p examples/pts2.pbm try.png
132-- ./sam2p examples/pts2.pbm try.tiff
133-- ./sam2p examples/pts2.pbm try.xpm
134-- ./sam2p examples/pts2.pbm try.bmp
135-- ./sam2p examples/pts2.pbm try.jpg
136
137A really short User's guide
138"""""""""""""""""""""""""""
139To convert an image, call:
140
141        ./sam2p <INPUT.IMG> <OUTPUT.IMG>
142        Example: ./sam2p examples/pts2.pbm try.eps
143
144To print an image as a full PostScript page, call:
145
146        ./sam2p [MARGIN-SPECS] <INPUT.IMG> ps: - | lpr
147        Example: ./sam2p -m:1cm examples/pts2.pbm ps: - | lpr
148
149To convert an image to be included as EPS (Encapsulated PostScript) into
150(La)TeX documents, call:
151
152        ./sam2p <INPUT.IMG> <OUTPUT.eps>
153        Example: ./sam2p examples/pts2.pbm test.eps
154        In file.tex: \usepackage{graphicx} ... \includegraphics{test}
155
156To convert an image to be included as PDF into pdf(La)TeX documents, call:
157
158        ./sam2p <INPUT.IMG> <OUTPUT.pdf>
159        Example: ./sam2p examples/pts2.pbm test.pdf
160        In file.tex: \usepackage{graphicx} ... \includegraphics{test}
161
162If you have a large image file (possibly originating from dumb software),
163you can reduce the image size and keep the same filename. (Please note that
164some meta-information may be lost using this method.) This operation is
165_DANGEROUS_ if you don't have a backup, because due to a software or
166hardware problem, sam2p might clobber time image file so the actual image
167gets lost. To overwrite a file in-place, call:
168
169        ./sam2p <INPUT-OUTPUT.IMG> --
170        Example: ./sam2p test.tiff --
171
172You may specify a compression method (or supply other command line options)
173to make a file even smaller, call:
174
175        ./sam2p [OPTIONS] <INPUT.IMG> <OUTPUT.IMG>
176        Example: ./sam2p -c:zip test.tiff test2.tiff
177
178See the detailed documentation of available command-line options elsewhere
179in this document. You may also read section {FAQ} for more information.
180
181Too see a list about the supported input and output image file formats, call:
182
183        ./sam2p
184
185Example output:
186
187        This is sam2p v0.39.
188        Available Loaders: JAI PNG JPEG TIFF PNM BMP GIF LBM XPM PCX TGA.
189        Available Appliers: XWD Meta Empty BMP PNG TIFF6 TIFF6-JAI JPEG-JAI JPEG PNM GIF89a XPM PSL1C PSL23+PDF PDF-JAI PSL2-JAI l1fa85g P-TrOpBb.
190        Usage: [...]
191
192The list of ``Available Loaders'' lists the input image file formats. All
193except for JAI are self-explanatory. JAI is JPEG-as-is, it means reading a
194JPEG file and writing back the exactly same image into an other JPEG variant,
195without quality loss.
196
197From the list of ``Available Appliers'' one can derive the supported output
198image file formats. XWD, BMP, PNG, TIFF6, JPEG, PNM, GIF89a and XPM are
199self-explanatory. TIFF6-JAI, JPEG-JAI, PDF-JAI and PSL2-JAI are JPEG
200variants into which JAI files (see above) can be saved. While the names of
201the remaining appliers may be quite cryptic to the beginner user; most of
202those appliers provide sam2p's excellent support for writing PS, EPS and
203PDF files.
204
205sam2p operation modes
206~~~~~~~~~~~~~~~~~~~~~
207sam2p is a command line utility (i.e, without a graphical user
208interface), so it can be used by composing a command line with the
209appropriate options and parameters, and launching it. See sections ``Turbo
210tutorial'' and ``One-liner mode'' for more details.
211
212sam2p is not interactive, it doesn't ask questions; thus it is completely
213suitable for batch processing and automation. sam2p doesn't log errors, but
214its STDERR can be redirected to a log file quite easily.
215
216There are three modes sam2p can operate in:
217
218-- one-liner mode: (since sam2p 0.37)
219   the user, perhaps, has to type a long command line, specifying the input
220   and the output file name, output file format, compression options, etc.
221   Most of the functionality of sam2p is available in a quite intuitive way
222   in one-liner mode. Users of the `convert' utility from ImageMagick and
223   `tiff2ps' and `tiffcp' will find that one-liner mode of sam2p is very
224   similar to them. This mode is recommended for impatient users.
225
226   Due to the nature of sam2p development, some new functionality of job mode
227   might be missing from one-liner mode. Please report this as a bug.
228
229-- job mode: the user has to write a ``job'' file (recommended extension:
230   .job), which specifies all conversion parameters, including the input and
231   output file name. The name of the job file must be passed to sam2p. This
232   mode is recommended for expert users who want to retain full control of
233   all aspects of the final output. All functionality is available in job
234   mode. This is especially useful in repetative but time separated jobs.
235
236-- GUI mode: This is completely experimental, and will be very probably
237   dropped in the near future. Try executing sam2p.tk (TCL/Tk is required).
238   Please don't use GUI mode, use one-liner mode instead! The flexability
239   of a one-liner (or job) mode is nearly imposible to encompas in a GUI.
240   No more documentation is provided for GUI mode.
241   
242   There might be a Micro$oft Windoze version of sam2p available in the near
243   future, but very probably you won't get real GUI with radio boxes, lists
244   and file selection dialogs. You'll have to start sam2p from the DOS
245   prompt...
246
247One-liner mode
248~~~~~~~~~~~~~~
249This section contains a reference-style summary for the one-liner mode.
250The author knows that this section is quite incomprehensible, and a bit old.
251He is planning to completely rewrite it to be readable for the novice user.
252
253The order of the arguments and options is significant.
254
255Input file extension is discarded. The file format is recognised by its
256magic number.
257
258Output file extension gives a hint for /FileFormat:
259
260.ps    :\
261 .eps  :  \                        where PS: implies scale to fit page
262 .epsi :   >  PSL1 PSLC PSL2 PSL3                     and
263 .epsf :  /                             EPS: implies no scale changes
264 [E]PS::/                               also see Q9 in FAQs below
265.pdf   : \  PDF1.0 PDF1.2 (and)
266  PDF: : /    PDFB1.0 PDFB1.2
267.gif   : GIF89a
268.pnm   : PNM (for use with transparency)
269.pbm   : PNM /SampleFormat/Gray1
270.pgm   : PNM /SampleFormat/Gray8
271.ppm   : PNM /SampleForamt/Rgb8
272.pam   : PAM
273.pip   : PIP
274.empty : Empty
275.meta  : Meta
276.jpeg  : JPEG
277 .jpg  :  "
278.tiff  : TIFF
279 .tif  :  "
280.png   : PNG
281.xpm   : XPM
282.bmp   : BMP /Compression/RLE
283.rle   : BMP /Compression/RLE
284
285Options (case insensitive):
286
287-- --tmpremove {true|false} : remove temporary files after completion.
288      Set to false for debugging.  Default: true.
289-- -j -j:job   : display in-memory .job file
290-- -j:warn     : be verbose and display warnings about impossible combinations in
291                 the .job file
292-- -j:quiet    : print only error and fatal error messages, suppress
293                 warnings, notices etc. Must be put at the beginning of the
294                 command line to suppress initial banners, too. For example,
295                 `sam2p -j:quiet in.gif out.eps'.
296-- -s:Indexed1:Indexed4:Indexed8: Try /SampleFormats in this order, and try
297                 all others after these. Can be specified separately
298                 (e.g `-s Indexed1 -s Indexed2:Indexed8')
299-- -s:Indexed1:Indexed4:Indexed8:stop: Try only these /SampleFormats in
300                 this order. Can be specified separately
301                 (e.g `-s Indexed1:Indexed2 -s Indexed8:stop')
302-- -s:Indexed1:Indexed4:Indexed8:stopq: Try only these /SampleFormats in
303                 this order, be quiet (no warnings on failures). Can be
304                 specified separately (e.g `-s Indexed1:Indexed2 -s Indexed8:stop')
305-- -s:tr         equivalent to `-s Transparent:Opaque:Mask:Transparent2:Transparent4:Transparent8'
306-- -l:...      : /LoadHints(...)
307-- disabled: -a: /LoadHints(asis) extra /Compression/JAI; load JPEG files (and others as-is)
308
309-- -1  -ps:1 PSL1:         : [tiff2ps] hint /FileFormat/PSL1 among /PSL*
310-- -1c -ps:1c -ps:c PSLC:  : [pts] hint /FileFormat/PSLC among /PSL*
311-- -2  -ps:2 PSL2: EPS2:   : [tiff2ps,imagemagick] default hint /FileFormat/PSL2 among /PSL*
312-- -3  -ps:3 PSL3:         : [pts] hint /FileFormat/PSL3 among /PSL*
313-- -pdf:b0 PDFB1.0:        : [pts] hint /FileFormat/PDFB1.0 among /PDF* (PDF 1.0 with inline image)
314-- -pdf:b2 PDFB1.2:        : [pts] default hint /FileFormat/PDFB1.2 among /PDF* (PDF 1.2 with inline image; default because image processors usually keep inline images intact, so they wouldn't want to inefficiently recompress our image)
315-- -pdf:0 PDF1.0:          : [pts] hint /FileFormat/PDF1.0 among /PDF* (PDF 1.0 with XObject image)
316-- -pdf:2 PDF1.2:          : [pts] hint /FileFormat/PDF1.2 among /PDF* (PDF 1.2 with XObject image)
317--  EPS: EPSF:             : [pts] hint /FileFormat/PSL2 or
318                                        /FileFormat/PSL3 (for /Compression/ZIP)
319--  PDF:                   : [pts] hint /FileFormat/PDFB1.0 or
320                                        /FileFormat/PDFB1.2 (for /Compression/ZIP)
321--  PS:                    : [pts] hint /Scale/RotateOK /FileFormat/PSL2 or
322                                        /FileFormat/PSL3 (for /Compression/ZIP)
323--  PS2:                   : [imagemagick] hint /Scale/RotateOK
324                                                /FileFormat/PSL2. Deprecated, please use PS:.
325
326-- -e:0 -e:none            : /Scale/None
327-- -e -e:1 -e:scale        : /Scale/OK
328-- -e:rot -e:rotate        : /Scale/RotateOK
329
330-- GIF: GIF89a: : [imagemagick,pts] /FileFormat/GIF89a
331-- JPEG: JPG:   : [imagemagick,pts] /FileFormat/JPEG
332-- TIFF: TIF:   : [imagemagick,pts] /FileFormat/TIFF
333-- PNG:         : [imagemagick] /FileFormat/PNG
334-- XPM:         : [imagemagick] /FileFormat/XPM
335-- BMP:         : [imagemagick] /FileFormat/BMP
336-- Empty:       : [pts] /FileFormat/Empty
337-- Meta:        : [pts] /FileFormat/Meta
338-- PIP:         : [pts] /FileFormat/PIP
339-- PAM:         : [pts] /FileFormat/PAM
340-- PNM:         : [imagemagick] /FileFormat/PNM (for use with transparency)
341-- PBM:         : [imagemagick] /FileFormat/PNM /SampleFormat/Gray1
342-- PGM:         : [imagemagick] /FileFormat/PNM /SampleFormat/Gray8
343-- PPM:         : [imagemagick] /FileFormat/PNM /SampleFormat/Rgb8
344
345-- -t:bin             : [pts] hint /TransferEncoding/Binary (default unless /PS*)
346-- -t:hex             : [pts] hint /TransferEncoding/Hex (default for /PSL1 /PSLC)
347-- -t:a85             : [pts] hint /TransferEncoding/A85 (default for /PSL2 /PSL3)
348-- -t:ascii           : [pts] hint /TransferEncoding/ASCII
349-- -t:lsb1 -f:lsb2msb : [pts,tiffcp] hint /TransferEncoding/LSBfirst
350-- -t:msb1 -f:msb2lsb : [pts,tiffcp] hint /TransferEncoding/MSBfirst
351
352-- -c:none                 : [pts,tiffcp] non-default hint /Compression/None
353-- -c:lzw                  : [pts,tiffcp] hint /Compression/LZW
354-- -c:lzw:(1..99)          : [pts] hint /Compression/LZW /Predictor ...
355-- -c:zip                  : [pts,tiffcp] hint /Compression/ZIP
356-- -c:zip:(1..99)          : [pts] hint /Compression/ZIP /Predictor ...
357-- -c:zip:(1..99):(-1..9)  : [pts] hint /Compression/ZIP /Predictor ... /Effort ...
358-- -c:(rle|packbits)       : [pts,tiffcp] hint /Compression/RLE
359-- -c:(rle|packbits):(0..) : [pts] hint /Compression/RLE /RecordSize ...
360-- -c:fax                  : [pts] hint /Compression/Fax
361-- -c:fax:(-1..)           : [pts] hint /Compression/Fax /K ...
362-- -c:dct                  : [pts] hint /Compression/DCT /DCT<<>>
363-- -c:dct:...              : [pts] hint /Compression/DCT /DCT<<...>>
364-- -c:jpeg                 : [pts,tiffcp] hint /Compression/JAI, /Compression/IJG
365-- -c:jpeg:(0..100)        : [pts] hint /Compression/JAI, /Compression/IJG /Quality ...
366-- -c:ijgi                 : [pts,tiffcp] hint /Compression/IJG
367-- -c:ijg:(0..100)         : [pts] hint /Compression/IJG /Quality ...
368-- -c:g4                   : [pts] equivalent to -c:fax:-1
369-- -c:g3 -c:g3:1d          : [pts] equivalent to -c:fax:0, -c:fax
370-- -c:g3:2d                : [pts] equivalent to -c:fax:-2
371-- -c:jai                  : [pts] hint /Compression/JAI
372
373-- -m:dpi:(dimen)      : set /ImageDPI to `dimen'
374-- -m:(dimen) \        : set all margins (/TopMargin,/BottomMargin, /LeftMargin, /RightMargin) to `dimen'
375   -m:all:(dimen) \    :                  /LeftMargin, /RightMargin) to `dimen'
376   -m:a:(dimen)        :
377-- -m:horiz:(dimen) \  : set /LeftMargin and /RightMargin to `dimen'
378   -m:h:(dimen) \      :
379   -m:x:(dimen)        :
380-- -m:vert:(dimen) \   : set /TopMargin and /BottomMargin to `dimen'
381   -m:v:(dimen) \      :
382   -m:y:(dimen)        :
383-- -m:left:(dimen) \   : set /LeftMargin to `dimen'
384   -m:l:(dimen)        :
385-- -m:right:(dimen) \  : set /RightMargin to `dimen'
386   -m:r:(dimen)        :
387-- -m:top:(dimen) \    : set /TopMargin to `dimen'
388   -m:t:(dimen) \      :
389   -m:up:(dimen) \     :
390   -m:u:(dimen)        :
391-- -m:bottom:(dimen) \ : set /BottomMargin to `dimen'
392    -m:b:(dimen) \     :
393    -m:down:(dimen) \  :
394    -m:d:(dimen)       :
395
396-- --                  : if given as last arg, then   OutputFile:=InputFile
397-- --                  : if given earlier than last arg, then    treat other args as filenames
398-- -transparent:(rgb) Change the all pixels having the specified RGB color
399   to transparent. Previously transparent pixels are not changed. See FAQ
400   answer A44 for an exampe.
401
402Default and fallback compression types for each file format:
403
404-- PSL1 PSLC                  : /RLE
405-- PSL2 PDFB1.0 PDF1.0        : /JAI /RLE
406-- PSL3 PDFB1.2 PDF1.2        : /JAI /ZIP
407-- GIF89a                     : /LZW
408-- XPM PNM PAM PIP Empty Meta : )/None)
409-- JPEG                       : /JAI /IJG
410-- TIFF                       : /JAI /LZW? /RLE
411-- PNG                        : /ZIP
412-- BMP                        : /RLE
413
414Overview of job mode
415~~~~~~~~~~~~~~~~~~~~
416In the ``job mode'' sam2p doesn't accept any command line options. It must be
417controlled from the ``job'' files. In ''job mode'' sam2p expects a single command
418line argument: the name of the Job file (file format described in section
419{Jobs}). sam2p runs that single job, prints debug, info, notice, warning and
420error messages (etc.), and creates a single output file: a PS or a PDF. For
421multiple jobs and/or multiple output files, one has to run sam2p multiple
422times.
423
424The details about the output file format (including standards-compliance,
425compression and transfer encoding) are specified in the Job file and other
426files. Thus, in order to make use of the (basic and) advanced
427features of sam2p in job mode, you have to:
428
4291. Understand the basic concepts (i.e read through this manual, and have a
430   look at the examples).
4312. Prepare the input raster (bitmap) graphics file in one of the supported
432   input formats (see section {Supported input formats}).
4333. Decide the name of the output file.
4344. Decide some or all details of the output format.
4355. Create a Job file that describes those details.
4366. Invoke the program `sam2p' with the name of the Job file as a single
437   command-line argument (or `-' if the Job file is fed on STDIN).
4387. Read warning and error messages (printed to STDOUT and STDERR), and retry
439   if necessary.
440
441Compilation and installation
442~~~~~~~~~~~~~~~~~~~~~~~~~~~~
443External software required for running sam2p:
444
445-- a UNIX system with a fairly standard BSD or POSIX C library (C++
446   libraries are not required), or a Win32 system with MSVCRT.DLL (install
447   Wordpad to get MSVCRT.DLL)
448-- optionally: the libjpeg `cjpeg' utility for /Compression/IJG
449-- optionally: the libjpeg `djpeg' utility for reading JPEG files
450-- optionally: tif22pnm (uses libtiff) from the author of sam2p
451-- optionally: png22pnm (uses libpng) from the author of sam2p
452-- optionally: the Ghostscript `gs' utility for /Compression/DCT
453-- optionally: the Ghostscript `gs' utility for /Compression/Fax
454
455These do not work yet (in version 0.44):
456
457-- optionally: the `lzw_codec' utility for alternative /Compression/LZW
458-- optionally: the GNU `gzip' utility for alternative /Compression/ZIP
459-- optionally: the Info-ZIP `zip' utility for alternative /Compression/ZIP
460
461For Win32 compilation, see later.
462
463Software required for UNIX compilation:
464
465-- a UNIX system
466-- a working, GNU-compatible C++ compiler (preferably GNU G++ >=2.91. Known
467   working compilers: g++-2.91 g++-2.95 g++-3.0 g++-3.1 g++-3.2)
468-- GNU Make (`make -v' should print `GNU Make')
469-- Perl >=5.004 (no external Perl modules are required)
470-- a Bourne-compatible shell (preferably GNU Bash >=2.0)
471-- the following libraries are _not_ required: libjpeg, libtiff, libpng,
472   libungif, PDFlib, zlib, libm, libstdc++
473-- optionally: GNU autoconf >=2.53 (version number is important, see
474   AC_C_CONST)
475
476Compilation:
477
478        # compile and install required programs
479        autoconf  # optional, for experts only
480        export CC=gcc-3.2 CXX=g++-3.2  # optional, for experts only
481        ./configure --enable-gif --enable-lzw
482        make
483        # the stand-alone utility `./sam2p' is now built
484        make install  # optional, may not work
485
486If installation doesn't work, please copy the file `sam2p' to somewhere in
487your $PATH, for example /usr/local/bin. Please also copy the README to a
488directory like /usr/share/doc/sam2p. There is no man page -- the
489documentation is the readme.
490
491Testing:
492
493        ./sam2p
494        ./sam2p examples/ptsbanner_zip.job
495        ./sam2p examples/pts2.pbm try.eps
496        gs test.ps
497        # try other examples: examples/*.job
498
499On Debian systems, you'll need GNU Make, Perl, GNU Bash and any of the
500following packages for compilation:
501
502        apt-get install libc6-dev gcc-2.95 g++-2.95
503        apt-get install libc6-dev gcc-3.0 g++-3.0
504        apt-get install libc6-dev gcc-3.1 g++-3.1
505        apt-get install libc6-dev gcc-3.2 g++-3.2
506        apt-get install libc6-dev gcc-3.3 g++-3.3
507        apt-get install libc6-dev gcc-3.4 g++-3.4
508
509Please also run any of the following before ./configure:
510
511        export CC=gcc-2.95 CXX=g++-2.95
512        export CC=gcc-3.0 CXX=g++-3.0 # or g++-3.1 etc.
513
514Optionally, you may install any of
515
516        apt-get install gccchecker
517        apt-get install autoconf
518
519sam2p has been tested with a wide variety of GNU C++ compilers, including
520g++-2.91, g++-2.95, g++-3.0, g++-3.1, g++-3.2, i386-uclibc-g++-2.95,
521checkerg++-2.95. The program must be compilable _without_ _warnings_ with
522any of g++-2.91, g++-2.95, g++-3.0, g++-3.1, g++-3.2. If there is a
523compilation error, send a brief e-mail to the author immediately!
524
525Portability
526~~~~~~~~~~~
527sam2p is quite portable on UNIX systems. It runs on:
528
529        Debian GNU/Linux Slink  2.2.13 glibc-2.0.7 (development platform)
530        Debian GNU/Linux Potato 2.2.18 glibc-2.1.3
531        Debian GNU/Linux Sid    2.4.17 glibc-2.2.5
532        Digital OSF1 V4.0 1229 alpha
533        Slackware 8.0/8.1       2.4.5  libc-2.2.3  gcc-2.95.3
534        SunOS 5.7 Generic_106541-17 sun4u sparc SUNW,Ultra-2 gcc-2.95.2
535        SunOS 5.8 Generic_108528-12 sun4u sparc gcc-3.0.4
536
537Also it runs on Win32 in command line (sam2p.exe) and GUI mode (vcsam2p.exe).
538Command line mode is stable and it is recommended on this platform.
539
540It should work on any Linux or BSD system without modification. Porting to
541other Unices should be quite easy. The author welcomes portability patches.
542
543Porting to non-UNIX systems may be hard. Reasons:
544
545-- Those systems might not have GNU Make, Perl or a Bourne-compatible shell
546   installed. So the Makefile supplied won't work, and many man hours of extra
547   work would be necessary.
548-- sam2p uses the popen(3) library call to communicate with external
549   processes. This call might not be available on non-UNIX systems.
550-- sam2p expects that the $PATH contains the external binaries. Some systems
551   tend to have empty or misconfigured $PATH. On some systems, `gs' is
552   called `gswin32c.exe' etc.
553
554sam2p 0.38 has been compiled and run successfully on:
555
556-- Linux 2.2.8 Debian Slink, g++-2.91
557-- Linux 2.4.18-ac3 Debian SID, g++-2.95, g++-3.0, g++-3.1, g++-3.2
558   Executable size: 318kB.
559-- Linux 2.4.2 Debian Potato, gcc version 2.95.2 20000220 (Debian GNU/Linux)
560   No warnings.
561   Compilation took 0:47, executable size: 330kB.
562-- Linux 2.2.16-3 Red Hat Linux release 6.2 (Zoot), gcc version egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)
563   No warnings.
564   Compilation took 0:44, executable size: 324kB.
565-- OSF1 V4.0 564 alpha, gcc version 2.7.2.2
566   (tons of: warning: cast discards `const' from pointer target type,
567    tons of: warning: the meaning of `\x' varies with -traditional
568    tons of: warning: cast increases required alignment of target type)
569   Compilation took 5 minutes, executable size: 550kB.
570-- SunOS 5.7 Generic_106541-19 sun4u sparc SUNW,Ultra-2, gcc version 3.1
571   (some: warning: cast from `char*' to `int*' increases required alignment of target type)
572   Compilation took 2:50, executable size: 437kB.
573-- SunOS 5.8 Generic_108528-15 sun4u sparc, gcc version 3.1.1
574   (some: warning: cast from `char*' to `int*' increases required alignment of target type)
575   Compilation took 1:26, executable size: 437kB.
576-- Slackware 8.0/8.1, kernel 2.4.5, libc.6.so (libc-2.2.3)  gcc-2.95.3
577
578sam2p 0.42 has been compiled and run successfully on:
579
580-- Windows 98, Visual C++ 6.0
581-- Windows 98, MSYS, MingGW, G++ 3.2
582
583Win32 compilation instructions for command-line mode
584~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
585To compile sam2p.exe, the Win32 equivalent of the UNIX utility sam2p, you
586have to install these build dependencies first:
587
588-- MinGW and MSYS, available from http://www.mingw.org
589
590-- Perl 5.004 or newer (only perl.exe and perl5*.dll are required), available
591   from http://www.perl.com. Note that this will be a long download and a
592   bloated install, but after that, just copy perl.exe and the single
593   perl5*.dll to your C:\WINDOWS directory, and uninstall the rest.
594
595To build sam2p:
596
5971. Install all the build dependencies.
598
5992. Open the MSYS terminal window from the start menu.
600
6013. Run `explorer .' to figure out what is the current working directory.
602   Let's call this directory the MSYS home.
603
6044. Download the sam2p sources into the MSYS home:
605
606        http://www.inf.bme.hu/~pts/sam2p-latest.tar.gz
607
6085. Unpack the sources. Run:
609
610        tar xzvf sam2p-latest.tar.gz
611        tar xvf sam2p-latest.tar.gz # if the previous one doesn't work
612
6136. Run `cd sam2p-*.*' to enter the sam2p source directory. It should contain
614   a newer version of this README and the file sam2p_main.cpp.
615
6167. Run `perl -edie' to check whether Perl is correctly installed. It should
617   print a line beginning with `Died '. If no such line appears (or you get
618   a `command not found' error message), go and install Perl first. Run
619   `echo $PATH' to find out where MSYS is searching for perl.exe. Copy
620   perl.exe to one of those directories.
621
6228. Run
623
624        ./configure --enable-gif --enable-lzw
625        make
626
6279. The file sam2p.exe is now created in the current directory. Use it. You
628   may copy it to another directory right now:
629
630        cp sam2p.exe 'C:\Program Files'
631
63210. You should invoke sam2p.exe from the command line (COMMAND.COM or
633    CMD.EXE) with the _appropriate_ arguments, described elsewhere in
634    this document. Don't put it into the Start menu, it won't work.
635    (a window will flash in and disappear, showing an error message that you
636    haven't supplied the right arguments).
637
63811. The file bts2.tth is also created. It is an important file, because it
639    is required for the GUI compilation.
640
64112. Don't forget to install tif22pnm.exe to load TIFF files, djpeg.exe to
642    load JPEG files, cjpeg.exe to save JPEG files, and png22pnm.exe to load
643    PNG files. The installation instructions for these programs are not
644    given here.
645
646Win32 compilation instructions for GUI mode
647~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
648vcsam2p.exe is a preliminary, alpha-stage attempt to provide a Win32 GUI for
649sam2p.exe. Currently it can load and display images, but not cannot save
650them. vcsam2p.exe is not ready for production use.  Feel free to enhance the
651code. Just remember to semd me copies.
652
653You'll need Visual Studio 6.0 installed.
654
6551. Download the sam2p sources:
656
657        http://www.inf.bme.hu/~pts/sam2p-latest.tar.gz
658
6592. Download untarka.exe to be able to unpack the sources:
660
661        http://www.inf.bme.hu/~pts/untarka.exe
662
6633. Unpack the sources. Run:
664
665        untarka.exe sam2p-latest.tar.gz
666
667   A directory sam2p-*.* will be created, containing a newer version of this
668   README and the file config-vc6.h
669
6704. You'll need bts2.tth. You can get an old, possibly outdated and buggy
671   version directly:
672
673        http://www.inf.bme.hu/~pts/bts2.tth
674
675   Or, you may compile sam2p under Linux (or Win32 command-line), and copy
676   the generated bts2.tth from there.
677
678   Copy bts2.tth to the same directory as config-vc6.h
679
6805. Start the Visual C++ 6.0 environment.
681
6826. File / Open Workspace / File type: Projects
683                           Filename: vcsam2p.dsp
684   Build / Set Active Configuration: vcsam2p - Win32 Release
685   Build / Build vcsam2p.exe
686   Build / Execute vcsam2p.exe
687
6887. Don't forget to install tif22pnm.exe to load TIFF files, djpeg.exe to
689   load JPEG files, cjpeg.exe to save JPEG files, and png22pnm.exe to load
690   PNG files. The installation instructions for these programs are not
691   given here.
692
693Please report and fix bugs in vcsam2p.exe
694
695Copyright
696~~~~~~~~~
697sam2p is written and owned by Szabó Péter <pts@fazekas.hu>. sam2p contains
698code from various people.
699
700sam2p may be used, modified and redistributed only under the terms of the
701GNU General Public License, found in the file COPYING in the distribution,
702or at
703                                                                               
704        http://www.fsf.org/licenses/gpl.html
705                                           
706Supported input formats
707~~~~~~~~~~~~~~~~~~~~~~~
708-- PNM, PBM, PGM, PPM (preferred formats for non-transparent images)
709-- PNM+PGM, PNM+PBM. The input is a concatenation of a PNM and a P[GB]M
710   file with the same dimensions. The second P[GB]M contains the alpha
711   channel.
712-- XPM (preferred formats for indexed images with transparency)
713-- BMP
714-- GIF, with transparency
715-- LBM (IFF ILBM), with transparency
716-- TGA (Targa)
717-- baseline JPEG JFIF (limited by /Compression/JAI)
718-- PCX
719-- JPEG, is supported with libjpeg/djpeg
720-- TIFF, is supported with the author's tif22pnm, with transparency; also
721   works in a limited way with tifftopnm (Debian package libtiff-tools)
722-- PNG, is supported with the author's png22pnm, with transparency
723   (part of the tif22pnm sources); also works in a limited way with
724    libpng/pngtopnm (Debian package graphics/pnmtopng); with transparency
725-- PS, EPS, PDF: Ghostscript is needed (`gs' or `gswin32c.exe'), see also FAQ
726   question Q39.
727
728Note that only the major features of these file formats are supported. sam2p
729is able to load most of these files, but not all of them.
730
731Important, but unsupported input formats:
732
733-- XBM
734-- XWD
735-- Utah RLE
736
737Input image model
738~~~~~~~~~~~~~~~~~
739A (sampled, raster, bitmap) image is a rectangular array of pixels (dots)
740plus some metadata. Each pixel is represented by an unsigned integer which
741is BPC (BitsPerComponent) and CPP (ComponentsPerPixel) wide. The image
742coordinate system (X,Y) is defined as: upper left corner is (0,0), upper
743right corner is (Width-1,0), lower right corner is (Width-1,Height-1).
744(Note that this is the natural, traditional top->down, left->right system,
745and it is different from PostScript and PDF!).
746
747Some pixels of the image may be without color: they're transparent. A
748transparent pixel is not painted, so whatever was left under it on the
749paper, remains visible. (On the other hand, a colored pixel overrides the
750pixel below unconditionally. E.g a white pixel overrides a black pixel, a
751half-gray pixel, and also another white pixel; but a transparent pixel
752leaves the original one visible.). Notions referring to transparent pixels
753are: transparency, opacity, transparent, opaque, alpha channel, matte
754channel.
755
756Images are read from image files on disk. The file format is autodetected
757(see section {Supported input formats}), and it can also be specified in the
758Job file (NOT implemented yet). Not all file formats are able to specify all
759pixel data and metadata, so additional hints (such as the transparent color
760or the name of the image author) can be specified in Job files.
761
762Sample formats
763~~~~~~~~~~~~~~
764The image pixels could be packed to bytes according to several sample
765formats. Each output file (both EPS and PDF) has its own SampleFormat
766(notation: capitals).
767
768A color is either transparent or it is an opaque RGB triplet (8*3 bits).
769
770The number of colors is the number of colors actually _used_. So unused
771palette entries, and e.g unused #555555 in gray-4 are not counted.
772
773If PSLC is required, but the printer is only PSL1, then the color image will
774be printed grayscale.
775
776When _choosing_ the output format, sam2p doesn't degrade image quality. For
777example, if an image has only two colors: #000001 and #ffffff, sam2p won't
778allow the gray-1 sample format, but with #000000 and #ffffff, it will. The
779user is expected to have an image editor in which she can adjust image
780colors precisely (such as in the Dialogs/(Indexed palette) dialog of The
781GIMP).
782
783Supported Sample Formats:
784
785Name:
786        Fast compatibility
787        Slow compatibility
788        Criteria for the image
789        -- Comment(...)
790
791transparent: (specialisation of mask)
792        all
793        -
794        the whole image is transparent
795        -- implemented with empty image body
796opaque: (specialisation of mask and indexed-1)
797        all
798        -
799        the whole image contains the same, opaque color
800        -- implemented with `setrgbcolor', `fill'
801mask: (specialisation of transparent-2)
802        all
803        -
804        a transparent and a non-transparent color (any may be missing)
805        -- display a Warning if the whole image is transparent or opaque,
806           because transparent or opaque would be a better choice
807        -- implemented with a single call to `imagemask'
808indexed-1:
809        all
810        -
811        exactly 2 non-transparent colors or 1 non-transparent color
812        -- display a Warning if only 1 non-transparent color, because
813           opaque would be a better choice
814        -- display a Notice if colors are in black (#000000) and white
815           (#ffffff), beacuse gray-1 would be a better choice
816        -- implemented with a `setrgbcolor', `fill', and a single call to
817           `imagemask'
818indexed-2:
819        PSL2, PDF1.0??
820        PSLC
821        3 or 4 non-transparent colors or 1..2 non-transparent colors
822        -- display a Warning if only 1..2 non-transparent colors, because
823           opaque or indexed-1 would be a better choice
824        -- display a Notice if colors are in (#000000, #555555, #aaaaaa,
825           #ffffff), beacuse gray-2 would be a better choice
826        -- implemented with the /Indexed color space or colorimage +
827           manual palette lookup
828        -- users with a PSL1 printer without PSLC should use transparent-*
829indexed-4:
830        PSL2, PDF1.0??
831        PSLC   
832        5..16 non-transparent colors or 1..4 non-transparent colors
833        -- display a Warning if only 1..4 non-transparent colors, because
834           opaque, indexed-1 or indexed-2 would be a better choice
835        -- display a Warning if all components are #00 or #ff,
836           because rgb-1 would be a better choice (3 bits over 4 bits)
837        -- display a Notice if colors are in (#000000, #111111, ...,
838           #ffffff), beacuse gray-4 would be a better choice
839        -- implemented with the /Indexed color space or colorimage +
840           manual palette lookup
841        -- users with a PSL1 printer without PSLC should use transparent-*
842indexed-8:
843        PSL2, PDF1.0??
844        PSLC
845        17..256 non-transparent colors or 1..16 non-transparent colors
846        -- display a Warning if only 1..16 non-transparent colors, because
847           opaque, indexed-1, indexed-2, indexed-4 would be a better
848           choice
849        -- display a Warning if all components are #00, #55, #aa or #ff,
850           because rgb-2 would be a better choice (6 bits over 8 bits)
851        -- display a Notice if all colors are gray, beacuse gray-8 would be
852           a better choice
853        -- implemented with the /Indexed color space or colorimage +
854           manual palette lookup
855        -- users with a PSL1 printer without PSLC should use transparent-*
856transparent-2:
857        all
858        -
859        0..1 transparent and 1..3 non-transparent colors
860        -- display a Notice that color separation was done (which can
861           decrease speed and compression)
862        -- display a Warning if no transparent color, because `indexed-2'
863           would be a better choice
864        -- display a Warning if only 1 non-transparent color, because `mask'
865           would be a better choice
866        -- implemented with multiple calls to `setrgbcolor', `imagemask'
867transparent-4:
868        all
869        -
870        a transparent and 1..15 non-transparent colors
871        -- display a Notice that color separation was done (which can
872           seriously decrease speed and compression)
873        -- display a Warning if only 1..3 non-transparent colors, because
874           `mask' or `transparent-2' would be a better choice
875        -- implemented with multiple calls to `setrgbcolor', `imagemask'
876transparent-8:
877        all
878        -
879        a transparent and 1..255 non-transparent colors
880        -- display a Warning that color separation was done (which can
881           seriously decrease speed and compression)
882        -- display a Warning if only 1..15 non-transparent colors, because
883           `mask', `transparent-2' or `transparent-4' would be a better
884           choice
885        -- implemented with multiple calls to `setrgbcolor', `imagemask'
886gray-1:
887        all
888        -
889        colors are in black (#000000) and white (#ffffff)
890        -- display a Warning if only 1 color, because opaque would be a
891           better choice
892        -- implemented with the multiple-argument `image'
893gray-2:
894        all
895        -
896        colors are in (#000000, #555555, #aaaaaa, #ffffff)
897        -- display a Warning if only 1..2 colors, because opaque,
898           indexed-1, or gray-1 would be a better choice
899        -- implemented with the multiple-argument `image'
900gray-4:
901        all
902        -
903        colors are in (#000000, #111111, ..., #ffffff)
904        -- display a Warning if only 1..4 colors, because opaque,
905           indexed-1, gray-1, indexed-2 or gray-2 would be a better choice
906        -- implemented with the multiple-argument `image'
907gray-8:
908        all
909        -
910        colors must be gray
911        -- display a Warning if only 1..16 colors, because opaque,
912           indexed-1, gray-1, indexed-2, gray-2, indexed-4 or gray-4
913           would be a better choice
914        -- implemented with the multiple-argument `image'
915rgb-1:
916        PSLC, PDF1.0
917        -
918        color components must be #00 or #ff (8 colors max)
919        -- display a Warning if all colors are gray
920        -- display a Warning if only 1..4 colors, because opaque,
921           indexed-1, indexed-2 (or gray-*) would be a better choice
922        -- implemented with `colorimage'
923rgb-2:
924        PSLC, PDF1.0
925        -
926        color components must be #00, #55, #aa or #ff (64 colors max)
927        -- display a Warning if all colors are gray
928        -- display a Warning if only 1..16 colors, because opaque,
929           indexed-1, indexed-2 or indexed-4 (or gray-*) would be a better choice
930           choice (this includes the case when color components are in
931           #00, #ff)
932        -- implemented with `colorimage'
933rgb-4:
934        PSLC, PDF1.0
935        -
936        color components must be #00, #11, ... #ff (4096 colors max)
937        -- display a Warning if all colors are gray
938        -- display a Warning if only 1..256 colors, because opaque,
939           indexed-1, indexed-2, indexed-4 or indexed-8 (or gray-*) would be a better
940           choice (this includes the case when color components are in
941           #00, #55, #aa, #ff)
942        -- implemented with `colorimage'
943rgb-8:
944        PSLC, PDF1.0
945        -
946        no transparency
947        -- display a Warning if all colors are gray
948        -- display a Warning if only 1..256 colors, because opaque,
949           indexed-1, indexed-2, indexed-4 or indexed-8 (or gray-*) would be a better
950           choice
951        -- display a Warning if all color components are in
952           #00, #11, ... #ff, because rgb-4 would be a better choice
953        -- implemented with `colorimage'
954
955The following directed (acyclic) graph represents that some formats should
956be tried earlier than others to avoid most Warning and Notice messages. The
957graph was created according to the descriptions above.
958
959        EarlierFormat LaterFormat
960
961        transparent mask                                     
962        opaque mask
963        opaque indexed-1
964        indexed-1 indexed-2
965        indexed-2 indexed-4
966        indexed-4 indexed-8
967        gray-1 gray-2
968        gray-2 gray-4
969        gray-4 gray-8
970        rgb-1 rgb-2
971        rgb-2 rgb-4
972        rgb-4 rgb-8
973        gray-1 indexed-1
974        gray-2 indexed-2
975        gray-4 indexed-4
976        gray-8 indexed-8 
977        rgb-1 indexed-4   
978        rgb-2 indexed-8   
979        mask transparent-2
980        transparent-2 transparent-4
981        transparent-4 transparent-8
982        opaque gray-1   
983        indexed-1 gray-2
984        indexed-2 gray-4
985        indexed-4 gray-8
986        opaque rgb-1   
987        gray-1 rgb-1
988        gray-2 rgb-2   
989        gray-4 rgb-4   
990        gray-8 rgb-8   
991        indexed-2 rgb-1
992        indexed-4 rgb-2
993        indexed-8 rgb-4
994        indexed-8 rgb-8
995
996Every directed acyclic graph (DAG) has a topological ordering on its nodes.
997Such an ordering can be computed by the UNIX (Version 7 AT&T UNIX) utility
998tsort(1). Its output on the author's machine:
999
1000        opaque
1001        transparent
1002        gray-1
1003        indexed-1
1004        mask
1005        transparent-2
1006        gray-2
1007        indexed-2
1008        transparent-4
1009        rgb-1
1010        gray-4
1011        indexed-4
1012        transparent-8
1013        rgb-2
1014        gray-8
1015        indexed-8
1016        rgb-4
1017        rgb-8
1018
1019This ordering should be taken into account when someone develops her
1020Rule Profile. Rules having SampleFormats listed earlier should be earlier in
1021the Rule Profile to avoid Warning and Notice messages.
1022
1023The availability (and also Warnings and Notices) of a Sample Format for a
1024particular image can be easily decided after answering the following
1025characteristic questions:
1026
1027-- Is transparency _used_?
1028-- How many _used_ non-transparent colors are there? (257 if >=257)
1029-- Is there a non-gray color?
1030-- How many bits are required (maximum) for each component?
1031
1032Output rules
1033~~~~~~~~~~~~
1034Every detail of the output file format is precisely determined by the Output
1035Rule. The Output Rule may be specified in the Job file, or is
1036automatically chosen from several pre-defined output rules in the Output
1037Profile (see section {Output profiles} elsewhere in this document).
1038
1039Output rule entries:
1040
1041-- FileFormat: enum (see section {Standards} for detailed information), no
1042   default
1043   /PSL1      -- PostScript Level1
1044   /PSLC      -- PostScript Level1 with the CMYK and `colorimage' extension
1045   /PSL2      -- PostScript Level2 (default)
1046   /PSL3      -- PostScript Level3
1047   /PDFB1.0   -- PDF version 1.0, BI inline image, see 4.8.6 in PDFRef.pdf
1048   /PDFB1.2   -- PDF version 1.2, BI inline image, see 4.8.6 in PDFRef.pdf
1049   /PDF1.0    -- PDF version 1.0, XObject image, see 4.8.4 in PDFRef.pdf
1050   /PDF1.2    -- PDF version 1.2, XObject image, see 4.8.4 in PDFRef.pdf
1051   /GIF89a
1052   /Empty
1053   /Meta
1054   /PNM
1055   /PAM
1056   /PIP
1057   /TIFF
1058   /JPEG
1059   /PNG
1060   /XPM
1061
1062-- SampleFormat: enum, no default, see section {Sample formats}
1063   /Opaque
1064   /Transparent
1065   /Gray1
1066   /Indexed1
1067   /Mask
1068   /Transparent2
1069   /Gray2
1070   /Indexed2
1071   /Transparent4
1072   /Rgb1
1073   /Gray4
1074   /Indexed4
1075   /Transparent8
1076   /Rgb2
1077   /Gray8
1078   /Indexed8
1079   /Rgb4
1080   /Rgb8
1081   /Asis       -- accept contents of the JAI file
1082   /Bbox       -- no image, only bounding box information
1083-- WarningOK: boolean; this Output Rule is enabled iff WarningOK is true or
1084   SampleFormat causes no warnings, default: true
1085-- TransferEncoding: enum, no default
1086   /Binary -- Binary (RawBits, see pbm(5), pgm(5), ppm(5)) (Binary integers
1087   are stored in any byte order allowed by /FileFormat)
1088   /ASCII -- ASCII (text, chars: 9,10,13,32..126), used with transparent and opaque
1089   /Hex /AHx -- Hex ((PSL1), PDF1.0, PSL2 ASCIIHexEncode filter)
1090   /A85 -- A85 (PSL2 PDF1.0, ASCII85Encode filter)
1091   /MSBfirst -- Binary data with integers stored in MSB first byte order.
1092     If 0x41424344 is represented as "ABCD", the byte order is called: big
1093     endian, MSB, MSB first (preferred), most significant byte first, most
1094     significant bit first, MSB-to-LSB, network byte order, m68k byte order.
1095     QuarkXPress 3 can read only TIFF files with MSB-to-LSB byte order.
1096   /LSBfirst -- Binary data with integers stored in LSB first byte order.
1097     If 0x41424344 is represented as "DCBA", the byte order is called:
1098     little endian, LSB, LSB first (preferred), least significant byte
1099     first, least significant bit first, LSB-to-MSB, VAX byte order, PC
1100     (i386) byte order.
1101-- Compression: enum
1102   /None -- None (default)
1103   /LZW -- LZW (PSL2 PDF1.0 LZWEncode filter EarlyChange=true, UnitLength=8
1104     LowBitFirst=false)
1105   /ZIP /Flate /Fl -- ZIP (PSL3 PDF1.2 FlateEncode filter without options)
1106   /RLE /RunLength /RunLengthEncoded /RL /PackBits -- RLE (PSL2 PDF1.0
1107     RunLengthEncode filter, similar to TIFF PackBits)
1108   /Fax /CCITTFax /CCF -- Fax (PSL2 PDF1.0 CCITTFaxEncode filter,
1109     Uncompressed=true!, K=-1,0,1, EndOfLine=false, EncodedByteAlign=false,
1110     Columns=..., Rows=0, EndOfBlock=true, BlackIs1=false,
1111     DamagedRowsBeforeError=0)
1112   /DCT -- DCT (PSL2 PDF1.0 DCTEncode, options in JPEG
1113     stream)
1114   /IJG /JPEG /JPG /JFIF -- IJG (PSL2 PDF1.0 DCTEncode, options in JPEG
1115     stream; the IJG libjpeg library is used for compression, respecting the
1116     quality value 0..100). This requires /SampleFormat/Rgb8 or
1117     /SampleFormat/Gray8. This doesn't work with /SampleFormat/Asis.
1118   /JAI -- JAI (PSL2 PDF1.0 DCTEncode, options in JPEG stream; JPEG-as-is: the
1119     input file must be a JPEG file -- its contents are transferred
1120     unmodified into the /DCTDecode JPEG stream). This requires
1121     /SampleFormat/Asis, and doesn't work with any other /SampleFormats
1122-- Predictor: enum (see later), default: 25, numbering same as PSL1 filter.
1123   1 -- no predictor. (default) Must be this unless Compression is /LZW or
1124        /Flate
1125   2 -- TIFF predictor 2 (horizontal differencing)
1126   10 -- PNG predictor, None function
1127   11 -- PNG predictor, Sub function
1128   12 -- PNG predictor, Up function
1129   13 -- PNG predictor, Average function
1130   14 -- PNG predictor, Paeth function
1131   15 -- PNG predcitor, individually chosen for each line (absolute minimum)
1132         This is the same as what libpng uses by default when creating PNG.
1133   25 -- Pick 15 or 1 based on the SampleFormat: use 15 for Gray8 and Rgb8,
1134         and use 1 (no predictor) for everything else. This is the default.
1135   45 -- PNG predcitor, individually chosen for each line (unsigned minimum)
1136         Don't use this, it is quite inefficient.
1137   55 -- PNG predcitor, individually chosen for each line (signed minimum)
1138         Don't use this, it is quite inefficient.
1139
1140-- Transparent: color. Default: null. Specify a color forced to be
1141   transparent. Old transparency, if exists, is blacked!
1142-- Hints: dict
1143   see below
1144
1145The Hints member of the Output Rule contains a dict with the following
1146elements:
1147
1148-- TopMargin           : dimen; desired vertical gap between the top line of the page
1149                           and the top line of the raster. Default: 0. Ignored unless for PS
1150                           and PDF output. See docs about `dimen' elsewhere in this document.
1151-- BottomMargin        : dimen; desired vertical gap between the bottom line of the
1152                           raster and the bottom line of the page. Default: 0. Ignored unless
1153                           for PS and PDF output. See docs about `dimen' elsewhere in this document.
1154-- LeftMargin          : dimen; desired horizontal gap between the left line of the page and
1155                           the left line of the raster. Default: 0. Ignored unless for PS and PDF
1156                           output. See docs about `dimen' elsewhere in this document.
1157-- RightMargin         : dimen; desired horizontal gap between the right line of the raster and
1158                           the right line of the page. Default: 0. Ignored unless for PS and PDF
1159                           output. See docs about `dimen' elsewhere in this document.
1160-- ImageDPI            : positive number; resolution of bitmap image in dots per inch.
1161                           Default: 72, which means no scaling.
1162-- Scale               : enum /None -- don't scale (zoom, magnify) the image (default)
1163                              /OK -- scale PS image to fit page (x factor == y factor)
1164                              /RotateOK -- scale and/or rotate PS image to fit page (x factor == y factor)
1165-- EncoderBPL          : int >=1 (bits per scanline, <= rlen)
1166-- EncoderCoumns       : int >=1 (pixels per scanline)
1167-- EncoderRows         : int >=1
1168-- EncoderColors       : int >=1
1169-- PredictorColumns    : uint; also used if compression is /Fax (reasonable default)
1170-- PredictorColors     : 1..3; number of color _components_ (reasonable default)
1171-- PredictorBPC        : 1, 2, 4, 8 (reasonable default), /BitsPerComponent entry in PS and PDF
1172-- Effort              : -1..9, must be -1 unless Compression is /ZIP (-1 means 5, default)
1173-- RecordSize          : uint, default: 0. Compression must be /RLE
1174-- K                   : int, default:  0 (-2..infty). Compression must be /Fax.
1175                                       -1 means G4 1d encoding,
1176                                        0 meangs G3 1D encoding,
1177                                       -2 means G3 2D encoding with  arbitrary height, positive value
1178                                       means G3 2D encoding with that height.
1179-- Quality             : 0..100, used by IJG libjpeg when compression is /IJG. default: 75
1180-- ColorTransform      : 0..2. For IJG, this _must_ be 0 for Gray and 1 for RGB, so its value
1181                           is ignored. For DCT, its value is respected: use 0 or 1 only.  See DCTEncode
1182                           in subsubsection 3.13.3 in PLRM.pdf, and for a better documentation: see the
1183                           sources and docs of libjpeg.
1184-- TransferCPL         : number of data characters per line. Must be positive when TransferEncoding is
1185                           /Hex or /A85, and must be zero otherwise.  Default: 78
1186-- DCT                 : dict, default: <<>>. Additional parameters for the /DCTEncode filter
1187-- Comment             : string, default: empty
1188-- Title               : string, default: empty
1189-- Subject             : string, default: empty
1190-- Author              : string, default: empty
1191-- Creator             : string, default: empty
1192-- Producer            : string, default: empty
1193-- Created             : string, default: now
1194-- Produced            : string: default: now
1195
1196Metric units
1197""""""""""""
1198Certain parameters have type `dimen'. This is a metric dimension, measured
1199in any of the following real-word distance metric units:
1200
1201--  1 bp = 1 bp (big point)
1202--  1 in = 72 bp (inch)
1203--  1 pt = 72/72.27 bp (point)
1204--  1 pc = 12*72/72.27 bp (pica)
1205--  1 dd = 1238/1157*72/72.27 bp (didot point) [about 1.06601110141206 bp]
1206--  1 cc = 12*1238/1157*72/72.27 bp (cicero)
1207--  1 sp = 72/72.27/65536 bp (scaled point)
1208--  1 cm = 72/2.54 bp (centimeter)
1209--  1 mm = 7.2/2.54 bp (millimeter)
1210
1211Note: If it helps: American typesetters use 72 points per US inch,
1212thus  10 pt text will yield 72 chars per normal line of US Letter
1213      (like an IBM Selectric)
1214      12 pt text will yield 65 chars per normal line of US Letter
1215     (US normal typewritter).
1216
1217Each image pixel is assumed to be 1 bp wide and 1 bp tall. A dimen is an
1218integer or real number, followed by optional whitespace and an optional unit
1219(any of `bp', `in', `pt', `pc', `dd', `cc', `sp', `cm', `mm'). The default
1220unit is `bp', i.e a bare number is a dimen measured in `bp'. The following
1221dimens are all one inch long: `72', `72bp', `72 bp', `1in', `1 in',
1222`2.54cm', `25.4mm', `72.27pt', `6pc', `4736286.72sp'.
1223
1224Note: MiniPS and TeX use the same units.
1225
1226OutputRule combinations
1227~~~~~~~~~~~~~~~~~~~~~~~
1228In the final version of sam2p, the following combinations will be supported:
1229
1230LZW >=2 Binary|Hex|A85 >=PSL2|>=PDF1.0 Mask|Gray*|RGB*|Indexed*
1231LZW >=2 Binary|Hex|A85 >=PSL2|>=PDF1.0 Transparent+
1232ZIP >=2 Binary|Hex|A85 >=PSL3|>=PDF1.2 Mask|Gray*|RGB*|Indexed*
1233ZIP >=2 Binary|Hex|A85 >=PSL3|>=PDF1.2 Transparent+
1234None|ZIP|LZW|RLE|Fax|DCT|IJG 1 Binary|Hex|A85 >=PSL2|>=PDF1.0 Mask|Gray*|RGB*|Indexed*
1235None|ZIP|LZW|RLE|Fax|DCT|IJG 1 Binary|Hex|A85 >=PSL2|>=PDF1.0 Transparent+
1236None 1 ASCII >=PSL1|>=PDF1.0 Opaque
1237None 1 ASCII >=PSL1|>=PDF1.0 Transparent
1238ZIP  1 Binary|Hex|A85 >=PSL1 Gray*|RGB*|Indexed*
1239ZIP  1 Binary|Hex|A85 >=PSL1 Mask|Gray1|Indexed1
1240ZIP  1 Binary|Hex|A85 >=PSL1 Transparent+
1241None 1 Binary|Hex|A85 >=PSL1 Gray*|RGB*|Indexed*
1242None 1 Binary|Hex|A85 >=PSL1 Mask|Gray1|Indexed1
1243None 1 Binary|Hex|A85 >=PSL1 Transparent+
1244RLE  1 Binary|Hex|A85 >=PSL1 Gray*|RGB*|Indexed*
1245RLE  1 Binary|Hex|A85 >=PSL1 Mask|Gray1|Indexed1
1246RLE  1 Binary|Hex|A85 >=PSL1 Transparent+
1247JAI  1 Binary|Hex|A85 >=PSL2|>=PDF1.0 Asis
1248
1249TTM files
1250~~~~~~~~~
1251TTM stands for Template Toy Macro.
1252
1253A TTM file is a dirty hack for generating templates with auto-calculated
1254lengths and offsets. Currently they are used for generating PDF output files
1255(/FileFormat/PDFB10 etc.). The syntax
1256of a TTM file is MiniPS (i.e a minimalistic PostScript, similar to .job
1257files). The TTM file must contain a single MiniPS array.
1258
1259The elements of the array are called chunks. Each chunk causes some bytes
1260to be appended to the output file. Data is appended in the order the
1261chunks are listed in the TTM file, but the data calculation order may be
1262different. This way it is possible to write (calc) the length of a chunk
1263not written (filled in) yet. The very first chunk has number zero.
1264different. This way it is possible to write the length of a chunk not
1265written yet. The very first chunk has number zero.
1266
1267The chunk types:
1268
1269-- string: backtick-sequences will be substituted (e.g ``w' to the width of
1270   the image, in pixels) by writeTemplate(). The result is appended to the
1271   output file.
1272-- positive integer: The offset (zero-based byte-position of the very first
1273   character of chunk 0) of the specified chunk will be appended to
1274   the output file. Only chunks already appearead may be specified this
1275   way. If the specified chunk is an array, then printf("%10u") will be
1276   called to print the number (this is useful for making PDF xref tables),
1277   otherwise printf("%u") will be called.
1278-- negative integer: The length (measured in bytes, after substitutions)
1279   of the specified chunk will be appended to the output file, using
1280   printf("%u"). Only chunks already calculated may be specified this way.
1281-- zero: error
1282-- array: the array is interpreted as a standalone TTM subfile, and the rules
1283   are applied recursively. This subfile contains sub-chunks, and the
1284   subchunks may be arrays themselves.
1285-- other MiniPS types: error
1286
1287The chunks are calculated in the following order: first the array chunks are
1288calculated (recursively) in order of appearance, followed by the non-array
1289chunks in order of appearance.
1290
1291A TTM file can have up to 64 top-level chunks.
1292
1293Example:
1294
1295        [ 1              %0
1296          [ (pts) ]      %1.0
1297          -1             %2
1298        ]
1299
1300The output file will be: `3pts0000000001' since chunk 1 has length 3 and
1301offset 1.
1302
1303Example job file
1304~~~~~~~~~~~~~~~~
1305        <<%sam2p job
1306        % This is file (named test0.job).
1307        /InputFile  (test0.pbm)
1308        /OutputFile (test0.pdf)
1309        /Profile [
1310          % This in-line profile is preferred over the defaults
1311          << /FileFormat/PDF10 /SampleFormat/Gray1 /TransferEncoding/Binary
1312             /Compression/Fax /Hints<</K 99>> >>
1313          (pdf10.jib) run  % elements found in external file
1314        ]
1315        >>
1316
1317See the directory examples/*.job in the sam2p sources.
1318
1319FAQ
1320~~~
1321Q1. Should I care about /LoadHints (,asis,) when loading JPEG files?
1322
1323A1. No, sam2p guesses it by magic (in both job mode and one-liner mode).
1324    However, you may want to set it manually in job mode:
1325
1326        /LoadHints () % use djpeg
1327        /LoadHints (,asis,) % don't use djpeg
1328        % nothing: automatic guess, based on /Compression/JAI
1329
1330Q2. How do I convert a JPEG file to PostScript Level2 EPS?
1331
1332A2. In one-liner mode, just run:
1333
1334        ./sam2p <INPUT.jpg> <OUTPUT.eps>
1335        Example: ./sam2p try.jpg try.eps
1336
1337    In one-liner mode, if you have both the djpeg and cjpeg utilities
1338    (budled with libjpeg from IJG (Independent JPEG Group)), _and_ you want
1339    to adjust quality vs size of the output, just run:
1340
1341        ./sam2p -c:jpeg:<QUALITY> <INPUT.jpg> <OUTPUT.eps>
1342        Example: ./sam2p -c:jpeg:60 try.jpg try.eps
1343
1344    In job mode, just run sam2p with the following .job file:
1345
1346        <<%sam2p-job;
1347        % conversion is possible without external utilities cjpeg and djpeg
1348        % No quality loss, just verbatim adata copying.
1349        /InputFile  (INPUT.jpg)
1350        /OutputFile (OUTPUT.eps)
1351        /Profile [
1352          << /FileFormat/PSL2 /SampleFormat/Asis /TransferEncoding/A85
1353             /Compression/JAI >>
1354        ] >>
1355
1356    Alternatively, to adjust quality vs size, use the following .job file:
1357
1358        <<%sam2p-job;
1359        % external utilities cjpeg and djpeg are required
1360        % This uses a JPEG decompression (djpeg), plus lossy JPEG compression
1361        % (cjpeg), so there might be quality loss!
1362        /InputFile  (INPUT.jpg)
1363        /OutputFile (OUTPUT.eps)
1364        /Profile [
1365          << /FileFormat/PSL2 /SampleFormat/Rgb8 /TransferEncoding/A85
1366             /Compression/IJG /Hints <<
1367               /Quality 40 % 0..100 (should be at least around 30)
1368          >> >>
1369        ] >>
1370
1371Q3. How do I convert a GIF file to PostScript Level2 EPS?
1372
1373A3. Check that sam2p has been compiled with GIF support: run sam2p, and
1374    examine its console output. It should contain a line:
1375
1376        Available Loaders: ... GIF ...
1377
1378    If GIF doesn't appear in the line, please recompile sam2p with:
1379
1380        make clean
1381        ./configure --enable-gif --enable-lzw
1382        make
1383        cp sam2p /usr/local/bin
1384
1385    After that, run sam2p again, and check for the line above again.
1386
1387    In one-liner mode, just run:
1388
1389        ./sam2p <INPUT.gif> <OUTPUT.eps>
1390        Example: ./sam2p try.gif try.eps
1391
1392    In job mode, if the GIF file doesn't have transparent pixels, run sam2p
1393    with the following .job file:
1394
1395        <<%sam2p-job;
1396        /InputFile  (INPUT.gif)
1397        /OutputFile (OUTPUT.eps)
1398        /Profile [
1399          << /FileFormat/PSL2 /SampleFormat/Indexed8 /TransferEncoding/A85
1400             /Compression/None >>
1401        ] >>
1402
1403    If the GIF file has transparent pixels, run sam2p with the following .job
1404    file:
1405
1406        <<%sam2p-job;
1407        /InputFile  (INPUT.gif)
1408        /OutputFile (OUTPUT.eps)
1409        /Profile [
1410          << /FileFormat/PSL2 /SampleFormat/Transparent8 /TransferEncoding/A85
1411             /Compression/None >>
1412        ] >>
1413
1414Q4. How do I covert a JPEG file to a TIFF/JPEG output file?
1415
1416A4. A TIFF/JPEG file is a TIFF file (_not_ a JPEG file!), in which the image
1417    data is compressed with JPEG (DCTEncode compression). The Compression
1418    TIFF tag value is 7. (There is also Compression==6, which corresponds to
1419    the old, obsolete JPEG format defined in the old TIFF6.0 spec.)
1420
1421    In one-liner mode, autodetection is magical. Just run:
1422
1423        ./sam2p <INPUT.jpg> <OUTPUT.tiff>
1424        Example: ./sam2p try.jpg try.tiff
1425
1426    In job mode, run sam2p with the following .job file:
1427
1428        <<%sam2p-job;
1429        /InputFile  (INPUT.jpg)
1430        /OutputFile (OUTPUT.tiff)
1431        %/LoadHints (asis) % default for /Compression/JAI
1432        /Profile [
1433          << /FileFormat/TIFF /SampleFormat/Asis /TransferEncoding/Binary
1434             /Compression/JAI >>
1435        ] >>
1436
1437    See also {FAQ question Q5} for compatibility notes.
1438
1439Q5. The TIFF/JPEG file generated by sam2p is invalid! I cannot read it with
1440    any programs.
1441
1442A5. No, it isn't invalid, but most of the programs (including those found in
1443    libtiff) cannot deal with TIFF files with JPEG compression.
1444
1445    Compatibility notes:
1446
1447    -- tif22pnm 0.03 (from the author of sam2p) can read TIFF/JPEG files
1448       perfectly. That's because it calls the TIFFRGBAImageGet() function
1449       of libtiff, which works.
1450
1451    -- sam2p 0.37 can read TIFF/JPEG files, beacuse it calls tif22pnm to do
1452       the job. Sam2p can write TIFF/JPEG files as well.
1453
1454    -- GIMP 1.0.2: error message: `Unknown photometric number 6'. GIMP TIFF
1455       import filter cannot deal with the YCbCr color space (which is the
1456       most common and de facto standard color space in non-grayscale JPEG
1457       files). It works, however, with grayscale JPEGs.
1458
1459    -- tifftopnm from libtiff-tools 3.4beta037-5.1: `unknown photometric:
1460       6'. Ditto. (Unfortunately tifftopnm doesn't call TIFFRGBAImageGet(),
1461       it just tries to re-implement an obsolete version of the function.)
1462
1463    -- `tiffcp -c jpeg' from libtiff-tools 3.4beta037-5.1 creates a
1464       perfectly legal TIFF/JPEG file.
1465
1466    -- tiffcp from libtiff-tools 3.4beta037-5.1 cannot load a file created
1467       by itself (`tiffcp -c jpeg')! There is no problem with grayscale
1468       images, but color images have one component removed.
1469
1470    -- xv 3.10a: Ditto.
1471
1472    -- display from ImageMagick 4.04: strange error message about libraries:
1473       `JPEGLib: Wrong JPEG library version: library is 61, caller expects 62.'
1474
1475    Simple conclusion:
1476
1477    -- Use sam2p or `tiffcp -c jpeg' to create a TIFF/JPEG. (Be aware that
1478       `tiffcp -c jpeg' cannot read a TIFF/JPEG: it can only create one.)
1479    -- Use tif22pnm to load or decode a TIFF/JPEG.
1480    -- In your own C programs, call the TIFFRGBAImageGet() function to read
1481       TIFF image data.
1482    -- Don't use anything else if you want to avoid compatibility problems.
1483
1484Q6. Does sam2p support transparency and alpha channels?
1485
1486A6. sam2p supports only bilevel transparency (i.e a pixel is either fully
1487    opaque or fully transparent), and only with indexed images. Transparency
1488    is supported when loading indexed PNG, TIFF, PNM, GIF, LBM and XPM files.
1489    A PNM file with transparency is a regular PBM/PGM/PPM file with a
1490    PBM image appended to it as the alpha channel (black pixel is
1491    transparent).
1492
1493    For transparent output, the user has to specify /Transparent, /Mask,
1494    /Transparent2, /Transparent4 or /Transparent8 as /SampleFormat. This
1495    works with:
1496
1497    -- /FileFormat/PSL1+    /SampleFormat/Transparent
1498    -- /FileFormat/PDF1.0+  /SampleFormat/Transparent
1499    -- /FileFormat/PDFB1.0+ /SampleFormat/Transparent
1500    -- /FileFormat/PSL1+    /SampleFormat/Mask
1501    -- /FileFormat/PDF1.0+  /SampleFormat/Mask
1502    -- /FileFormat/PDFB1.0+ /SampleFormat/Mask
1503    -- /FileFormat/GIF89a   /SampleFormat/Mask
1504    -- /FileFormat/PNM      /SampleFormat/Mask
1505    -- /FileFormat/TIFF     /SampleFormat/Mask
1506    -- /FileFormat/PNG      /SampleFormat/Mask
1507    -- /FileFormat/XPM      /SampleFormat/Mask
1508    -- /FileFormat/PSL1+    /SampleFromat/Transparent+
1509    -- /FileFormat/GIF89a   /SampleFormat/Transparent+
1510    -- /FileFormat/PNM      /SampleFormat/Transparent+
1511    -- /FileFormat/TIFF     /SampleFormat/Transparent+
1512    -- /FileFormat/PNG      /SampleFormat/Transparent+
1513    -- /FileFormat/XPM      /SampleFormat/Transparent+
1514
1515Q7. How large is a pixel of PostScript and PDF files generated by sam2p in
1516    real-world metric units (inches or centimeters)?
1517
1518A7. 72 big points == 1 inch == 2.54 centimeters
1519
1520    1 pixel == 1 big point
1521
1522Q8. I have an image with transparent pixels. What happens if I convert it to
1523    /Rgb* or /Gray*?
1524
1525A8. Either of the following will happen:
1526
1527    -- You get an error message, sam2p refuses to ignore transparency.
1528       Please use /SampleFormat/Transparent+, or call an image manipulation
1529       program to remove transparency from the image before feeding it to
1530       sam2p.
1531    -- Transparency information will be lost, and the color of formerly
1532       transparent pixels will be undefined. This would be a bug in sam2p,
1533       you should report it.
1534
1535    However, if you loaded a GIF file, and
1536    transformed it to /Gray8 or /Rgb8, the original palette entry (RGB
1537    triplet) is faithfully preserved.
1538
1539Q9. How do I generate a PostScript page ready for immediate printing with
1540    margins and the image properly scaled to fit the page?
1541    How do I create a PostScript file that will automatically scale the
1542    image to the maximum when printed?
1543
1544
1545A9. To print an image as a full PostScript page, call:
1546
1547        ./sam2p [MARGIN-SPECS] <INPUT.IMG> ps: - | lpr
1548        Example: ./sam2p -m:1cm examples/pts2.pbm ps: - | lpr
1549
1550    To create a PostScript file for printing, call:
1551
1552        ./sam2p [MARGIN-SPECS] <INPUT.IMG> [ps:] <OUTPUT.ps>
1553        Example: ./sam2p -m:1cm examples/pts2.pbm try.ps
1554
1555    The `-m' option above is sets all four margins to `1 cm'. You can
1556    set the margins individually:
1557
1558        Example: ./sam2p -m:left:7mm -m:right:1cm -m:top:0.5in \
1559          -m:bottom:18bp examples/pts2.pbm try.ps
1560
1561    As you can see in this example, you may specify dimensions in various
1562    metric units, see subsection {Metric units}.
1563
1564    You are strongly encouraged to print raster images with sam2p. Be aware
1565    that The GIMP 1.2 printing plugin has several weird contrast setting
1566    problems (even for /Gray1 images); white pixels will be gray etc. Other
1567    utilities may add unnecessary text banners or scale the image
1568    inappropriately.
1569
1570    In one-liner mode, sam2p guesses from the file extension and the selector
1571    (`ps:') whether the desired output file format is PostScript (fit single
1572    page) or Encapsulated PostScript (leave size as-is, suitable for
1573    inclusion into TeX documents).
1574
1575    In job mode, without /Scale/OK and /Scale/RotateOK in /Hints,
1576    sam2p outputs EPS (Encapsulated PostScript) with /FileFormat/PSL*. EPS
1577    files should be included as figures into other documents (such as TeX
1578    and InDesign), not printed alone. If you just want to print a sampled
1579    image alone, please use your favourite graphics manipulation program
1580    instead of sam2p.
1581
1582    In job mode, create a .job file for the EPS file, and add /Hints. For
1583    example:
1584
1585     <<%sam2p-job;
1586     /InputFile  (test.in)
1587     /OutputFile (test.ps)
1588     /Profile [
1589       << /FileFormat/PSL2 /SampleFormat/Rgb8 /TransferEncoding/A85
1590          /Compression/None /Predictor 1
1591          /Hints << /Scale/OK % or /Scale/RotateOK
1592                    /LeftMargin 12 % measured as number/72 inches
1593                    /Rightargin 12 % measured as number/72 inches
1594                    /TopMargin 12 % measured as number/72 inches
1595                    /BottomMargin 12 % measured as number/72 inches
1596                 >>
1597       >>
1598      ]
1599     >>
1600
1601Q10. Do the EPS files created by sam2p conform to some specifications?
1602
1603     The EPS output of sam2p conforms to the following Adobe specifications:
1604
1605        5001.DSC_Spec.pdf
1606        5002.EPSF_Spec.pdf
1607
1608     DSC and ADSC are: Adobe Document Structuring Conventions. They are
1609     comments with lines beginning with `%!' and `%%' in PS and EPS files.
1610
1611     An excerpt:
1612
1613        The following example illustrates the proper use of DSC comments in a
1614        typical page description that an application might produce when including an
1615        EPS file. For an EPS file that is represented as
1616
1617        %!PS-Adobe-3.0 EPSF-3.0
1618        %%BoundingBox: 4 4 608 407
1619        %%Title: (ARTWORK.EPS)
1620        %%CreationDate: (10/17/89) (5:04 PM)
1621        %%EndComments
1622        ...PostScript code for illustration..
1623        showpage
1624        %%EOF
1625
1626     DSC comments discussion:
1627
1628        %!PS-Adobe-3.0 EPSF-3.0 (mandatory)
1629        %%BoundingBox: ... ... ... ... (mandatory)
1630
1631        %%Extensions: CMYK (optional, for /PSLC)
1632        %%LanguageLevel: 2 (optional, for /PSL2)
1633        %%LanguageLevel: 3 (optional, for /PSL3)
1634        %%Creation (strongly recommended)
1635        %%Title (strongly recommended)
1636        %%CreationDate (strongly recommended)
1637        %%Trailer (optional)
1638        %%EOF (optional)
1639        %%DocumentData: Clean7Bit (optional)
1640        %%DocumentData: Binary (optional)
1641
1642Q11. I get the error message `sam2p: Error: applyProfile: invalid
1643     combination, no applicable OutputRule'. Help!
1644
1645A11. This error message means you have requested an invalid combination of
1646     FileFormat, SampleFormat, Compression etc. parameters. If you use
1647     one-liner mode, and you're sure that you've specified your will
1648     correctly in the command line, please report this error message as a
1649     sam2p bug (also specify -j in the command line). If you use job mode,
1650     please read on.
1651
1652     Example 1:
1653       /Compression/Fax is not allowed in /PSL1.
1654
1655     Solution 1:
1656       specify /FileFormat/PSL2 /Compression/Fax.
1657
1658     Example 2:
1659       /Compression/IJG requires /SampleFormat/Gray8 or /SampleFormat/Rgb8.
1660       Please have a look at the messages `sam2p: Warning: check_rule: ...'
1661       to get more specific information. After that, correct your request.
1662
1663     Solution 2:
1664       specify /Compression/IJG /SampleFormat/Rgb8.
1665
1666     Another cause for this message is that your request cannot be applied
1667     to the image you've specified. In this case, there is no relevant
1668     `sam2p: Warning: check_rule: ...' message.
1669
1670     Example 1:
1671       you've requested /SampleFormat/Indexed4,
1672       but the input image has more than 16 colors.
1673
1674     Solution 1:
1675       specify /SampleFormat/Rgb8.
1676
1677     Example 2:
1678       you've requested /SampleFormat/Indexed4,
1679       but the input image has transparency.
1680
1681     Solution 2:
1682       specify /SampleFormat/Transparent8.
1683
1684     It is possible, but very unlikely that this error message is caused by
1685     a bug in sam2p.
1686
1687Q12. Can I use /Compression/Fax when bits-per-pixel > 1 ?
1688
1689A12. With /FileFormat/PS* and /FileFormat/PDF*, you can (but you shouldn't,
1690     because of the possibly poor compression ratio). With /FileFormat/TIFF,
1691     you're not allowed to, because the TIFF specification forbids it.
1692     Example one-liners:
1693
1694        sam2p -s:Indexed8 -c:fax test.gif test.pdf   # OK
1695        sam2p -s:Indexed8 -c:fax test.gif test.eps   # OK
1696        sam2p -s:Indexed8 -c:fax test.gif test.tiff  # forbidden
1697
1698Q13. Bad luck?
1699
1700A13. Not for me.
1701
1702Q14. Can I use negative margins (i.e /TopMargin -20) to crop the output
1703     image?
1704
1705A14. No. Margins are ignored by sam2p unless /FileFormat is /PSL* or /PDF*.
1706     Even with these formats, the image is only moved, not cropped. Please
1707     use an image manipulation program (e.g The GIMP) to crop your images
1708     before feeding them to sam2p.
1709
1710Q15. When I try to print the PostScript output of sam2p, the edge of the
1711     image is missing (white).
1712
1713A15. Many printers cannot print to the edge of the paper (so that region is
1714     left white). Please increase the margins to a safe value, for example:
1715
1716        ./sam2p -m:7mm test.ppm test.ps
1717        lpr test.ps
1718
1719     See also {FAQ question Q9} for more information about margins.
1720
1721Q16. How do I report a bug in sam2p?
1722
1723A16. Please send an e-mail to the author (pts@fazekas.hu, see more in
1724     section {Copyright}) describing the problem. Don't forget to:
1725
1726     -- download the latest version of sam2p, and try it with the same image
1727     -- describe what sam2p does (incorrectly)
1728     -- describe what sam2p should do if there was no bug
1729     -- run sam2p without arguments, and attach its output (STDOUT) to the
1730        bug report
1731     -- attach the exact command line with which you call sam2p to the bug
1732        report
1733     -- if you spot the bug in one-liner mode, specify the `-j' option in
1734        the command line, and attach the messages printed by sam2p (both
1735        STDOUT and STDERR) to the bug report
1736     -- if you spot the bug in job mode, attach the .job file you are using
1737        to the bug report
1738     -- attach the input image file to the bug report. Try to attach a file
1739        as small as possible.
1740     -- if sam2p runs successfully (i.e it prints `Success.'), and it
1741        creates an output image, but you think that the output image is
1742        incorrect, attach the output image to your bug report
1743     -- if you have a similar input image, for which sam2p works fine,
1744        attach it to the bug report
1745
1746Q17. How long does the LZW patent held by Unisys last?
1747
1748A17. mcb@cloanto.com (author of http://lzw.info) wrote:
1749
1750     Thank you for your interest and mail. I must stress that the "exact"
1751     answers you may be looking for may come only from lawyers and courts,
1752     and I am none of these. If you consider the IBM, the BT and Unisys US
1753     patents, then the last of the three would be the Unisys one, expiring,
1754     as the article I think mentions, on June 19, 2003, 24:00. There cannot
1755     be other (new) patents on LZW, as far as I know. Please let me know if
1756     you find different information.
1757
1758Q18. I want to create an RGB PostScript image, but sam2p creates a Gray one,
1759     or it gives me an error message.
1760     For example: `./sam2p -1 -s:rgb1 examples/ptsbanner.gif test.eps'.
1761
1762A18. /PSL1 doesn't support RGB images. There are two solutions:
1763
1764     -- Use /PSLC or /PSL2 or /PSL3 instead or drop the '-1'
1765        alltogether. Examples:
1766
1767        ./sam2p -1c -s:rgb1 examples/ptsbanner.gif test.eps  # /PSLC
1768        ./sam2p -2  -s:rgb1 examples/ptsbanner.gif test.eps  # /PSL2
1769        ./sam2p     -s:rgb1 examples/ptsbanner.gif test.eps  # /PSL2 or /PSL3
1770
1771     -- Use /Mask or /Transparent+. Note that you'll very probably get poor
1772        compression ratio.
1773
1774        ./sam2p -1 -s:tr:stop examples/ptsbanner.gif test.eps  # /PSL1
1775
1776     You can get more (and more useful) error messages from sam2p if you
1777     specify the `-j:warn' option. You may also try specifying
1778     `-s:rgb1:stop' instead of `-s:rgb1' to force sam2p try /SampleFormat/Rgb1
1779     only.
1780
1781Q19. sam2p doesn't allow me to use /Compression /Fax. For example:
1782     `./sam2p -c fax examples/ptsbanner.gif test.eps'. The same command
1783     works fine without `-c fax'.
1784
1785A19. /Compression/Fax is intended to be used with images with 1 bit per
1786     pixel. However, in PostScript and PDF, you can use it for any image
1787     data, but compression ratio will be very poor for other than /Gray1,
1788     /Indexed1 or /Mask, of course. You can force sam2p to use /Fax by
1789     specifying the desired SampleFormat in option `-s'. Examples:
1790
1791        sam2p -s:Indexed8 -c:fax test.gif test.pdf   # OK
1792        sam2p -s:Indexed8 -c:fax test.gif test.eps   # OK
1793        sam2p -s:Indexed8 -c:fax test.gif test.tiff  # forbidden by TIFF std
1794     
1795     See {FAQ question Q12} for more information.
1796
1797Q20. Can sam2p convert images with transparency to PDF?
1798
1799A20. Only if the image has at most 1 non-transprent color
1800     (/SampleFormat/Mask). See {FAQ question Q6} for details.
1801     
1802     Although PDF-1.3 supports transparency masks for arbitrary PDF images,
1803     sam2p 0.39 doesn't. That's because the author of sam2p hasn't
1804     implemented it yet.
1805
1806Q21. I get the error message `sam2p: Warning: buildProfile: ignoring, no
1807     handlers for OutputRule'. Help!
1808
1809A21. This means that sam2p doesn't know how to do the conversion you've
1810     requested (and it even doesn't know whether the request is erroneous or
1811     not). This might be because your request is bad (it is impossible to
1812     be fulfilled), or your request is good, but sam2p doesn't know how to
1813     deal with it. If you think that the latter is the case, please report
1814     this message as a bug.
1815
1816     See {FAQ question Q11} for more information.
1817
1818Q22. How do I compile with G++ 3.2?
1819
1820A22. See the answer in section {Compilation and installation}. Don't forget
1821
1822        export CC=gcc-3.2 CXX=g++-3.2
1823
1824Q23. How do I do a `make dist' without running configure again?
1825
1826A23. Just issue
1827
1828        make MAKE_DIST=1 dist
1829
1830Q24. I cannot open a JPEG file in the Win32 version.
1831
1832A24. Make sure you have djpeg.exe on your PATH. Simply copy it to your
1833     C:\WINDOWS directory.
1834
1835Q25. I cannot open a TIFF file in the Win32 version.
1836
1837A25. Make sure you have tif22pnm.exe on your PATH. Simply copy it to your
1838     C:\WINDOWS directory.
1839
1840Q26. I cannot open a PNG file in the Win32 version.
1841
1842A26. Make sure you have png22pnm.exe on your PATH. Simply copy it to your
1843     C:\WINDOWS directory.
1844
1845Q27. What is tif22pnm?
1846
1847A27. tif22pnm is a TIFF -> PNM converter written by the author of sam2p. It
1848     can load more TIFF files correctly than tifftopnm, ImageMagick convert,
1849     xv and The GIMP. The TIFF loader code is based on GIMP 1.3, but has
1850     many bugfixes and improvements. sam2p uses tif22pnm to load TIFF files.
1851     You can download tif22pnm from
1852
1853        http://www.inf.bme.hu/~pts/tif22pnm-latest.tar.gz
1854
1855Q28. What is png22pnm?
1856
1857A28. png22pnm is a PNG -> PNM converter compiled by the author of sam2p. It
1858     is based on the excellent pngtopnm utility, but doesn't depend on the
1859     NetPBM library (only libpng). sam2p uses png22pnm (or, as a fallback:
1860     pngtopm) to load PNG files. png22pnm is part of the tif22pnm package,
1861     so you can download it from
1862
1863        http://www.inf.bme.hu/~pts/tif22pnm-latest.tar.gz
1864
1865Q29. Can sam2p convert a transparent GIF to PDF?
1866
1867A29. The PDF-1.3 file format supports transparent images, but sam2p doesn't.
1868     However, if the image contains at most two colors (including the
1869     transparent pixel), sam2p can create a working PDF-1.2 file; use
1870     Ghostscript to view it, because Acrobat Reader 5.0 is buggy. However,
1871     sam2p supports generating transparent EPS, GIF, PNG, PNM, XPM and TIFF
1872     files up to 256 colors.
1873
1874Q30. How do I build my own sam2p debian package?
1875
1876A30. Please download the newest sources from
1877
1878        http://www.inf.bme.hu/~pts/sam2p-latest.tar.gz
1879
1880     As root, run
1881
1882        apt-get update
1883        apt-get install debmake fakeroot dpkg
1884        apt-get install make g++ gcc perl sed
1885
1886     As normal user, run (in the directory containing sam2p_main.cpp):
1887
1888        debian/rules clean
1889        rm -f build*
1890        debian/rules build
1891        fakeroot debian/rules binary
1892        ls -l ../sam2p_*.deb
1893
1894     As root, substitute X and Y, and run:
1895
1896        dpkg -i sam2p_X_Y.deb
1897
1898     Please also install the tif22pnm and png22pnm packages from the author
1899     of sam2p (and the Debian standard libjpeg-progs package), available as
1900     Debian source from:
1901
1902        http://www.inf.bme.hu/~pts/tif22pnm-latest.tar.gz
1903
1904Q31. Why not use libjpeg/libtiff/libpng/zlib or any other library with
1905     sam2p?
1906
1907A31. -- library and .h incompatibilities (the binary would be less portable
1908        across Linux systems)
1909     -- to avoid forced dependencies
1910     -- checkergcc wouldn't work
1911
1912Q32. How do I specify the page size when printing a .ps file (-m and -e
1913     command line options)?
1914
1915A32. You cannot. (Use -m to specify the margins.) The page size is
1916     autodetected by your printer when the page is
1917     printed. So you can print the same .ps file on different printers, and the
1918     margins will be all right on all of them.
1919
1920     If you really have to specify the page size, edit the .ps file and
1921     insert the `a4 ' or `letter ' command after the last line of the
1922     first block of lines starting with %%. You may also use something like
1923     `1 dict dup /PageSize [ 595 842 ] put setpagedevice ' to exactly specify
1924     the page width and height in 1/72 inches.
1925
1926     For example, change the PostScript file
1927
1928       %!PS-Adobe-3.0
1929       %%Pages: 1
1930       %%DocumentData: Clean7Bit
1931       %%LanguageLevel: 1
1932       %%EndComments
1933       %%Page: 1 1
1934       save
1935       ... % many lines omitted
1936       %%Trailer
1937       %%EOF
1938
1939     to
1940
1941       %!PS-Adobe-3.0
1942       %%Pages: 1
1943       %%DocumentData: Clean7Bit
1944       %%LanguageLevel: 1
1945       %%EndComments
1946       %%Page: 1 1
1947       1 dict dup /PageSize [ 595 842 ] put setpagedevice
1948       save
1949       ... % many lines omitted
1950       %%Trailer
1951       %%EOF
1952
1953     Please note that PostScript is a programming language, so your changes
1954     might be undone by instructions later in the file. You might find the
1955     a2ping.pl utility (written by the author of sam2p) useful:
1956
1957       a2ping.pl -v --papersize=a4 in.ps out.ps
1958
1959Q33. How do I control ZIP compression ratio?
1960
1961A33. Use
1962
1963        sam2p -c:zip:1:0 in.img out.png  # uncompressed ZIP carrier
1964        sam2p -c:zip:1:1 in.img out.png  # normal compression
1965        sam2p -c:zip:1:9 in.img out.png  # maximum compression
1966
1967Q34. ImageMagick convert creates smaller PNGs. Why?
1968
1969A34. I don't know the real reason.  Probably because ImageMagick uses libpng,
1970     which is smarter than sam2p.
1971
1972     You are probably trying to convert a JPEG or other true color photo to
1973     PNG. Try one of the following compression options:
1974
1975        sam2p -c:zip:12:7   # 464727 bytes
1976        sam2p -c:zip:12:8   # 454271 bytes
1977        sam2p -c:zip:12:9   # 447525 bytes
1978        sam2p -c:zip:13:9   # 488748 bytes
1979        sam2p -c:zip:14:9   # 454182 bytes
1980        sam2p -c:zip:15:9   # 453080 bytes
1981        convert -quality ?  # 454438 bytes
1982
1983Q35. Can sam2p convert large JPEGs to smaller ones (with loss of
1984     quality and resolution)?
1985
1986A35. sam2p cannot resize or scale images. So the pixel width and height of
1987     the input and output image cannot be changed. If you need that (for
1988     example you want to create thumbnails), use the famous convert(1)
1989     utility of ImageMagick. For example:
1990
1991        convert -scale 444   -quality 50 in.jpg out.jpg  # specify out width
1992        convert -scale x444  -quality 50 in.jpg out.jpg  # specify out height
1993        convert -scale "10%" -quality 50 in.jpg out.jpg  # specify scale ratio
1994
1995     However, it is possible to specify the quality of the JPEG output of
1996     sam2p. The quality of 0 means ugly output with small file size, and the
1997     quality of 100 means nice output with big file sizes. You can specify
1998     intermediate integer quality values (50 and 75 are recommended). Be
1999     prepared that qualties above 30 (or so) may not work on all JPEG viewers.
2000     For example:
2001
2002         sam2p -c ijg:10 large_input.jpg small_output.jpg
2003
2004     sam2p uses the cjpeg(1) and djpeg(1) utilities from libjpeg to write
2005     and read JPEG files, respectively. If you need more control over your
2006     JPEG output, then forget sam2p, and please consult the documentation of
2007     those utilities.
2008
2009Q36. Can sam2p convert JPEG to GIF?
2010
2011A36. Yes, it can, but usually not directly. GIF allows a maximum of 256
2012     different
2013     colors in an image. A typical RGB JPEG image contains many more colors,
2014     so it has to be quantized down to 256 colors first. For example, if the
2015     console output of ``sam2p in.jpg out.gif'' contains ``applyProfile:
2016     invalid combination, no applicable OutputRule'', then in.jpg must be
2017     quantized first:
2018
2019        convert in.jpg out1.gif  # does the quantization automatically
2020        sam2p out1.gif out2.gif  # compresses the output image further
2021
2022     From out1.gif and out2.gif keep the one with the smaller file size. It
2023     is common that convert(1) creates huge GIF files because LZW compression
2024     is disabled inside it. sam2p should be compiled with LZW compression
2025     and GIF input/output enabled. To check this, run sam2p, and
2026     examine its console output. It should contain a line:
2027
2028        Available Appliers: ... GIF89a+LZW ...
2029
2030     If GIF89a+LZW doesn't appear in the line, please recompile sam2p with:
2031
2032        make clean
2033        ./configure --enable-gif --enable-lzw
2034        make
2035        cp sam2p /usr/local/bin
2036
2037     , and try again.
2038
2039Q37. I need to transform GIF images of 15 colors to BMPs of 256 colors not
2040     compressed. sam2p converts it to BMP 16 colors...
2041
2042A37. Use
2043
2044        sam2p -c none -s rgb8 in.gif out.bmp
2045
2046     If you get an error message `Error: applyProfile: invalid combination,
2047     no applicable OutputRule', it very probably means that your GIF is
2048     transparent. Remove the transparent color within an image editor first.
2049
2050Q38. Can sam2p _load_ PDF or EPS files?
2051
2052A38. Yes, if you have Ghostscript installed, and your input EPS file is not
2053     too exotic. This has been tested on Linux only. If you experience
2054     problems loading EPS files, but no problems loading PDF files, please
2055     run a2ping.pl written by the author of sam2p to make your EPS file more
2056     compatible.
2057
2058Q39. Can sam2p load an EPS or PDF file with an arbitrary resoultion?
2059
2060A39. Yes. For example use one of
2061
2062        sam2p -l:gs=-r216 in.eps out.png
2063        sam2p -l:gs=-r216 in.pdf out.png
2064
2065     to have resoultion 216 DPI (image scaled 3 times to both directions).
2066     Without scaling, 72 DPI is the default.
2067
2068Q40. Can sam2p emit a multi-page PDF or a multi-page PS?
2069
2070A40. No, it can't. Emitting a multi-page document would need a fundamental
2071     change of the sam2p architecture. (Should the 2nd page be compressed with
2072     a different method? What if the 2nd contains too many colors? Should we
2073     keep all previous pages in memory?)
2074
2075     I think another program should be written that is able to concatenate
2076     EPS/PS or PDF files. I've already written a PDF-merger called pdfconcat,
2077     available from http://www.inf.bme.hu/~pts/pdfconcat.c .
2078     An EPS-merger would be even easier. But I don't have time to
2079     implement these features directly into sam2p soon.
2080
2081Q41. Can sam2p read a multi-page TIFF?
2082
2083A41. sam2p reads only the first page.
2084
2085     The auxilary utility tif22pnm could be patched so it extracts other
2086     pages, and a new command line option can be added to sam2p that passes
2087     the required page number to tif22pnm. But I don't have time to
2088     implement these features soon.
2089
2090     By the way, multi-page TIFFs can be created with the following command:
2091
2092        tiffcp -c g4 d1.tiff d2.tiff d3.tiff output.tiff
2093
2094Q42. Can sam2p convert a multi-page TIFF to a multi-page PDF?
2095
2096A42. No. There are two main problems: See also Q40 and Q41.
2097
2098Q43. How do I convert a TIFF image to a 1-bit black-and-white PDF? Should I
2099     use `sam2p -c:fax test.tif test.pdf'?
2100
2101A43. The above will ensure that fax compression is used. What you need for
2102     ensuring that the output is 1-bit black-and-white is:
2103
2104        sam2p -s:gray1:stop test.tif test.pdf
2105
2106     You can also specify a compression algorithm (I recommend -c:zip):
2107
2108        sam2p -c:fax -s:gray1:stop test.tif test.pdf
2109        sam2p -c:lzw -s:gray1:stop test.tif test.pdf
2110        sam2p -c:zip -s:gray1:stop test.tif test.pdf
2111
2112     If you get the error message
2113
2114        sam2p: Error: applyProfile: invalid combination, no applicable OutputRule
2115
2116     then your input test.tif is not really black-and-white. Open it in an
2117     image editing program and ensure that the colors are #000000 and
2118     #ffffff only.
2119
2120     > The tiff is black and white, bilevel - I just want to avoid the
2121     > test.pdf from using 8bpp by default (like it does in imagemagick)
2122
2123     The default for sam2p is not 8bpp. To see what the default is, run sam2p
2124     with the `-j' option and check `OutputRule #1' on the console output.
2125     What you are interested in is the /SampleFormat field.
2126
2127Q43. Acrobat Reader (5.0 and 6.0) cannot read the PDFs converted from a JPEG
2128     with sam2p. I get the message: `There was an error processing a page.
2129     Expected `EI' while parsing an image.'.
2130     (The same problem happens with Ghostscript 6.50 with a different error
2131     message. xpdf-1.0 reports: bad DCT trailer.)
2132
2133A43. Very probably the JPEG stream of your original input image file is
2134     rejected by the PDF viewers. (In fact, Ghostscript 7.x doesn't
2135     complain.) sam2p doesn't do strict JPEG validation when converting JPEG
2136     to PDF -- it just blindly assumes that the JPEG file is correct. To
2137     ensure this, you have to re-encode the JPEG.
2138
2139     Instead of this:
2140
2141       sam2p bad.jpeg bad.pdf
2142
2143     do this:
2144
2145       sam2p -c ijg:50 bad.jpeg good.pdf  # much slower!
2146
2147     or this:
2148
2149       <bad.jpeg djpeg | cjpeg -quality 50 | sam2p - good.pdf
2150
2151     or this:
2152
2153        djpeg <bad.jpeg >temp.pnm
2154        cjpeg -quality 50 <temp.pnm >temp.jpeg
2155        sam2p temp.jpeg good.pdf
2156
2157     The real reason why Acrobat Reader rejects the JPEG is unknown to me.
2158     I also don't know of any baseline JPEG compliance testing software.
2159     (But if you re-encode with djpeg and cjpeg, it becomes compliant.)
2160
2161     (thanks to Thomas Kraemer for reporting the problem)
2162
2163Q44. How do I create an 1x1 transparent GIF and PNG?
2164
2165A44. Do
2166
2167        echo "P1 1 1 0" >one.pbm
2168        sam2p -transparent:ffffff one.pbm one.gif
2169        sam2p -transparent:ffffff one.pbm one.png
2170
2171Q45. Is it possible to specify a resolution other than 72 DPI, so that the
2172     dimensions of the resulting PDF are accurate for print-resolution images?
2173
2174A45. Yes, it is. Use `-m:dpi:144' to have the output EPS or PDF scaled to
2175     double size, or use `-m:dpi:<real>' to have it scaled by a factor of
2176     <real>/72, or 72/-<real>, if <real> is negative.
2177
2178     If you know that your input image resolution is <res> DPI, and you want
2179     to sam2p to create an EPS or PDF keeping the image resolution, you
2180     should use `-m:dpi:-<res>'.
2181
2182     Note that this works only for EPS and PDF output. For all other
2183     FileFormat{}s, `-m:dpi:' is ignored. The `-m:dpi:' option doesn't scale
2184     the values specified for the other `-m:...' options.
2185
2186     Some image file formats such as PNG an JPEG can contain resolution
2187     information. sam2p ignores this and assumes that the input image
2188     resolution is 72 DPI). It would be possible to improve sam2p to use
2189     this information, but it would be too much work.
2190
2191     To proper way of scaling an image, however, is
2192     using your DTP or word processor program to resize it properly. For
2193     example, after running `sam2p foo.png foo.pdf', in LaTeX, use
2194
2195        % \usepackage{graphicx}
2196        \includegraphics[height=10cm]{foo}
2197
2198Q46. Is it legal to use LZW compression?
2199
2200A46. I think so. Also look at Q17.
2201
2202Q47. Help! I cannot compile it on SunOS/Solaris. I get
2203
2204     /usr/include/sys/wait.h:90: type specifier omitted for parameter
2205     /usr/include/sys/wait.h:90: parse error before `*'
2206
2207A47. Until someone adds a test to ./configure, try adding the line
2208
2209       #define siginfo_t void
2210
2211     to the end of config2.h, just before running `make'.
2212
2213Q48. Should I run sam2p over all my EPS (or PDF) files, to see if they
2214     would become smaller?
2215
2216A48. No! This is a bad idea in general, because you lose information, since
2217     the EPS output of sam2p is always rasterized, so it is not scalable
2218     anymore.
2219
2220     But you may run sam2p over all those EPS files which contain raster
2221     graphics. But please be aware that sam2p re-renders everything at 72
2222     DPI (can be overridden by `-l:gs=-r<DPI>', and the gs rendering
2223     sometimes adjusts RGB color values slightly (+-2 on in the 0..255
2224     domain), so there might be quality loss during the _reading_ of the
2225     original EPS. There is absolutely no quality loss when sam2p _writes_
2226     the EPS.
2227
2228Q49. Should I run sam2p over all my GIF, TIFF and XPM files, to see if they
2229     would become smaller?
2230
2231A49. Yes, run `sam2p <filename> --' if you have a backup copy of the
2232     original. Otherwise, choose a different filename for output.
2233
2234Q50. Should I run sam2p over all my PNG files, to see if they
2235     would become smaller?
2236
2237A50. You might try it, there will be no quality loss, but the general
2238     experience of the author is that the tools using libpng (e.g. pnmtopng)
2239     produce slightly smaller PNG than sam2p. If you are an image
2240     compression specialist, please help the author to find the reason of
2241     this, and enhance sam2p.
2242
2243Q51. Should I run sam2p over all my JPEG files, to see if they
2244     would become smaller?
2245
2246A51. sam2p doesn't change the file by default. Use the `-c:ijg' option
2247     (possibly with a JPEG quality parameter, e.g. `-c:ijg:50') to make
2248     sam2p re-encode the JPEG. This is a lossy operation, and the size of
2249     the output file depends on quality parameter specified, so it might
2250     actually become larger than the original. Please also note that JPEG
2251     meta-information (such as EXIF tags inserted by digital cameras) gets
2252     completely lost with `-c:ijg'.
2253
2254Q52. How do I use ZIP (Deflate) compression in LanguageLevel 2?
2255
2256A52. Run this:
2257
2258        sam2p -c:zip PSL2: in.image out.eps
2259
2260     This will make sam2p emit the image decoding procedure so the image
2261     will be viewable (veeeery slowly) on LanguageLevel 2 devices, too. It
2262     doesn't affect the rendering speed on LanguageLevel 3 devices.
2263
2264Q53. How do I create a GIF from an image with more than 256 colors?
2265
2266A53. You need the pnmquant utility too from NetPbm. Run this:
2267
2268       sam2p in.image PPM:- | pnmquant 256 | sam2p - out.gif
2269
2270     Or, if you have the convert utility from ImageMagick, run:
2271
2272       sam2p in.image PPM:- | convert - out.gif
2273
2274Q54. What is the maximum image size sam2p supports?
2275
2276A54. As of version 0.45, the following limits apply for input images:
2277
2278     -- Input image height times image width must be <= 2000000000 pixels.
2279        Individual dimensions can be as high as necessary.
2280     -- Input image memory must be <= 1000000000 bytes (1 GiB). The memory is
2281        computed by multiplying image width, image height and BPC. BPC is
2282        number of bytes per pixels. It is 3 for RGB images, 1 for grayscale
2283        and indexed (256-color palette) images. For some temporary
2284        calculations BPC might go up to 3 even if it is smaller than 3 in
2285        the input image, so to be safe, always assume that BPC is 3 in image
2286        memory calculations.
2287     -- For JPEG input or ouput, image width and height must be <= 65535
2288        pixels.
2289        This is an inherent limitation in the JPEG file format.
2290
2291     In earlier versions (0.44 or below) the following additional limits
2292     applied:
2293
2294     -- Image width must be <= 65535 pixels.
2295     -- Image height must be <= 65535 pixels.
2296
2297     sam2p is a fast image conversion tool: it isn't unnecessarily slow on
2298     large images. Its speed is predictable for uncompressed images: it
2299     slows down proportionally to the input image memory (see the
2300     calculation below).
2301
2302Q55. How do I get the smallest PNG output?
2303
2304A55. If your input image is truecolor, please consider a lossy compression
2305     file format (such as JPEG), because the ZIP compression used in PNG is
2306     not particularly well-suited for truecolor images.
2307
2308     If your input image has only a few colors, specify `-c zip:25:9', which
2309     forces the ZIP compression whith a high effort (9) and predictor
2310     autodetection (25). This is considerably slower than not specifying any
2311     `-c' flag at all, and getting `-c zip:25', because the high effort (9)
2312     is slower than the default effort. Please note that `-c zip:25:9'
2313     disables the predictor unless the SampleFormat is Rgb8 or Gray8. (This
2314     is the same what libpng-1.2.15 does by default.) For large images (of
2315     Rgb{1,2,4,8} or Gray{1,2,4,8}), you may want to specify `-c zip:15:9'
2316     to forcibly enable the predictor, being autodetected for each image
2317     row.
2318
2319     Please also note that the free software ``optipng'' and the free-to-use
2320     closed-source software PNGOUT (for Win32, Linux and Mac OS X) can
2321     produce PNGs about 10% smaller than what sam2p produces -- but they are
2322     a 100 times (or even more) slower than sam2p. The tool ``pnmtopng''
2323     (tested with one linked to libpng 1.2.20) does not produce smaller PNGs
2324     than sam2p >= 0.46. For older versionf of sam2p, the output of
2325     ``pnmtopng'' was about 5--10% smaller.
2326
2327     Please also note that the the PNG output of Ghostscript -sDEVICE=pngmono
2328     etc. is not optimal. Convert it with sam2p or the tools mentioned above
2329     to reduce the file size.
2330
2331Q56. How do I get the smallest PDF output?
2332
2333A56. If your input image is truecolor, specify `-c jpeg', possibly tuning it
2334     with a low quality parameter e.g. `-c jpeg:30'.
2335
2336     If your input image has only a few colors, specify `-c zip:25:9' or
2337     `-c zip:15:9', see also Q55.
2338
2339     Please also have a look at Q55. Unfortunately, sam2p doesn't yet
2340     support calling external PNG optimizers and converting their output to
2341     PDF.
2342
2343Q57. Does sam2p convert images to canonical form, i.e. if I have two
2344     source images with identical width, height and RGB8 pixel
2345     representation, and I convert both with sam2p with the same flags,
2346     will the two output image files be byte-by-byte identical?
2347
2348A57. Yes, since version 0.46-2.
2349
2350     The only code code needed for that was sorting the indexed palette.
2351
2352     For blackbox input images which sam2p doesn't decompress (e.g. JPEG
2353     with /Compression/JAI), the output is only guaranteed to be
2354     byte-byte-byte identical, if the input was byte-byte-byte identical.
2355
2356Q58. Can sam2p generate a PDF which is scaled proportionally (i.e. keeping
2357     the aspect ratio) to a specified page size, and centered on the page?
2358
2359A58. No, but the Perl script sam2p_pdf_scale.pl bundled with sam2p can
2360     post-process the file created by sam2p. For example, to scale and
2361     center a PDF on an A4 paper, do:
2362
2363       $ sam2p input.img output.pdf
2364       $ sam2p_pdf_scale.pl 595 842 output.pdf
2365
2366     Please also have a look at the LaTeX package pdfpages.sty for more
2367     options. It can also be used to concatenate multiple PDFs.
2368     Its documentation:
2369     http://www.ctan.org/get/macros/latex/contrib/pdfpages/pdfpages.pdf
2370
2371     Example output.tex file:
2372
2373       \documentclass{article}
2374       \pdfcompresslevel9
2375       \paperwidth 21cm    \pdfpagewidth\paperwidth
2376       \paperheight29.7cm  \pdfpageheight\paperheight
2377       \usepackage{pdfpages}
2378       \begin{document}
2379       \includepdf{output_tmp.pdf}
2380       \end{document}
2381
2382     How to compile the .tex file above:
2383
2384       $ sam2p input.img output_tmp.pdf
2385       $ pdflatex output.tex
2386
2387     Please note that a2ping.pl or pdftk won't work either.
2388
2389Q59. How does sam2p detect the bounding box of PostScript and EPS input?
2390
2391A59. For PostScript input, the paper size specified in the PostScript code
2392     is used, reverting to the system's default paper size if missing.
2393     PostScript input is detected by finding `%!PS-Adobe-' at the beginning
2394     of the file, but `EPSF-' missing from the first line. Paper size can be
2395     specified in the PostScript code using `<</PageSize[...]>> setpagedevice', 'a4', `letter' etc.
2396     The comments `%%BoundingBox:' etc. are ignored.
2397
2398     For EPS input, the `%%ExactBoundingBox:' is used, reverting to
2399     `%%HiResBoundingBox:', reverting to `%%BoundingBox:', reverting to the
2400     system's default paper size. The paper size specified in the PostScript
2401     code is ignored. EPS input is detected by finding `%!PS-Adobe-' at the
2402     beginning of the file and `EPSF-' in the first line. When converting to
2403     PostScript, EPS or PDF, the (in.llx, in.lly) coordinates of the input
2404     bounding box are not preserved: the output file will always have (0, 0)
2405     as its lower left corner and (in.urx-in.llx, in.ury-in.lly) as its
2406     upper right corner.
2407
2408Upsampling
2409~~~~~~~~~~
2410Here is a figure about upsampling samples bits 1 -> 2 -> 4 -> 8:
2411
2412        0 -> 00                 0
2413        1 -> 11                 3
2414
2415        00 -> 0000              0
2416        01 -> 0101              5
2417        10 -> 1010              10
2418        11 -> 1111              15
2419
2420        0000 -> 0000 0000       0
2421        0001 -> 0001 0001       17
2422        0010 -> 0010 0010       34
2423        ...
2424        1110 -> 1110 1110       238
2425        1111 -> 1111 1111       255
2426
2427A 1-bit image has a palette of 2 colors: #00 and #ff.
2428
2429A 2-bit image has a palette of 4 colors: #00, #55, #aa and #ff.
2430
2431A 4-bit image has a palette of 16 colors: #00, #11, #22, ... #ff.
2432
2433An 8-bit image has a palette of 256 colors: #00, #01, #02, ... #ff.
2434
2435Standards
2436~~~~~~~~~
2437-- PSL1 is PostScript LanguageLevel1, as defined by Adobe's PostScript
2438   Language Reference Manual.
2439-- PSLC is PSL1 with the CMYK extension (including the `colorimage'
2440   operator). Supersedes PSL1.
2441-- PSL2 is PostScript LanguageLevel2, as defined by Adobe's PostScript
2442   Language Reference Manual. Supersedes PSLC.
2443-- PSL3 is PostScript LanguageLevel3, as defined by Adobe's PostScript
2444   Language Reference Manual (PLRM.pdf). Supersedes PSL2.
2445-- PDF1.0 is PDF version 1.0, as defined by Adobe's PDF Reference.
2446-- PDF1.1 is PDF version 1.1, as defined by Adobe's PDF Reference.
2447   Supersedes PDF1.0.
2448-- PDF1.2 is PDF version 1.2, as defined by Adobe's PDF Reference.
2449   Supersedes PDF1.1.
2450-- PDF1.3 is PDF version 1.3, as defined by Adobe's PDF Reference.
2451   Supersedes PDF1.2.
2452-- PDF1.4 is PDF version 1.4, as defined by Adobe's PDF Reference
2453   (PDFRef.pdf). Supersedes PDF1.3.
2454-- PDF1.5 is PDF version 1.4, as defined by Adobe's PDF Reference
2455   (PDFRef.pdf). Supersedes PDF1.4.
2456-- PBM is Portable Bitmap file format, as defined in NetPBM's pbm(5) UNIX
2457   manual page.
2458-- PGM is Portable Graymap file format, as defined in NetPBM's pgm(5) UNIX
2459   manual page.
2460-- PPM is Portable Pixmap file format, as defined in NetPBM's ppm(5) UNIX
2461   manual page.
2462-- PNM is Portable Anymap file format, as defined in NetPBM's pnm(5) UNIX
2463   manual page. It is the union of PGM, PPM and PPM.
2464-- PAM is the new, Portable ...map file format, as defined in NetPBM's pam(5)
2465   UNIX manual page. We don't support it yet.
2466-- TIFF is ... v6.0.
2467-- JPEG is baseline JPEG JFIF file format as defined by the Joint Picture
2468   Expert Group.
2469-- PNG is Portable Network Graphics file format v1.0, as defined by
2470   RFC 2083.
2471
2472
2473Obsolete: Image metadata
2474~~~~~~~~~~~~~~~~~~~~~~~~
2475-- Width: uint
2476-- Height: uint
2477-- ColorSpace: enum (see later), determines PixBits
2478-- PixBits: 1..24
2479-- Origin: coord
2480-- Comment: string
2481-- FileFormat:
2482-- Predictor: enum (see later), same as PSLanguageLevel1 filter
2483   /Predictor
2484   1 -- no predictor
2485   2 -- TIFF predictor 2 (horizontal differencing)
2486   10 -- PNG predictor, None function
2487   11 -- PNG predictor, Sub function
2488   12 -- PNG predictor, Up function
2489   13 -- PNG predictor, Average function
2490   14 -- PNG predictor, Paeth function
2491   15 -- PNG predcitor, individually chosen for each line
2492-- PredictorColumns: uint
2493-- PredictorColors: 1..3
2494-- PredictorBitsPerComponent: 1, 2, 4, 8
2495-- CompressionEffort: -1..9 (ZIP)
2496-- CompressionRecordSize: uint (RLE, Fax: K)
2497-- Compression: enum
2498   0 -- None
2499   1 -- LZW (PSL2 PDF1.0 LZWEncode filter EarlyChange=true, UnitLength=8
2500        LowBitFirst=false)
2501   2 -- ZIP (PSL3 PDF1.2 FlateEncode filter without options)
2502   3 -- RLE (PSL2 PDF1.0 RunLengthEncode filter, similar to TIFF PackBits)
2503   4 -- Fax (PSL2 PDF1.0 CCITTFaxEncode filter, Uncompressed=true!, K=-1,0,1,
2504        EndOfLine=false, EncodedByteAlign=false, Columns=..., Rows=0,
2505        EndOfBlock=true, BlackIs1=false, DamagedRowsBeforeError=0)
2506   5 -- DCT (PSL2 PDF1.0 DCTEncode, options in JPEG stream)
2507   6 -- IJG (PSL2 PDF1.0 DCTEncode, options in JPEG stream; the IJG libjpeg
2508        library is used for compression, respecting the quality value 0..100)
2509   7 -- JAI (PSL2 PDF1.0 DCTEncode, options in JPEG stream; JPEG-as-is: the
2510        input file must be a JPEG file -- its contents are transferred
2511        unmodified into the /DCTDecode JPEG stream)
2512-- TransferEncoding: enum
2513   0 -- Binary (RawBits, see pbm(5), pgm(5), ppm(5))
2514   1 -- ASCII (text, chars: 9,10,13,32..126)
2515   2 -- Hex ((PSL1), PDF1.0, PSL2 ASCIIHexEncode filter)
2516   3 -- 85 (PSL2 PDF1.0, ASCII85Encode filter)
2517   4 -- base64, _not_ implemented
2518   5 -- quoted-printable, _not_ implemented
2519   6 -- URLencode, _not_ implemented
2520
2521Compatibility notes
2522~~~~~~~~~~~~~~~~~~~
2523by pts@fazekas.hu at Wed Nov 14 12:14:15 CET 2001
2524Fri Mar 22 11:48:36 CET 2002
2525Sat Apr 20 19:57:44 CEST 2002
2526Fri Feb  7 11:15:39 CET 2003
2527
2528-- Ghostscript 6.50 has problems with /FileFormat/PDFB1.0
2529   /SampleFormat/JAI|/IJG/DCT
2530   (Error: /syntaxerror in ID). The problem has been fixed in Ghostscript
2531   7.04. With the buggy Ghostscript use /FileFormat/PDF1.0 instead.
2532-- /FileFormat/PDF[B]1.0 /SampleFormat/Mask|/Indexed1 doesn't
2533   work on Acrobat Reader 5.0 on Linux: a fully opaque, one-color rectangle is
2534   painted. This works fine on gs 6.50 and xpdf 1.0, so Acrobat Reader is
2535   assumed to be buggy.
2536-- The GIMP 1.0 cannot load PlanarConfig Separated TIFF images of type
2537   GrayA. (But can load PlanarConfig Contiguous GrayA.)
2538-- xv cannot display gray TIFF images with transparency.
2539   xv: Sorry, can not handle 2-channel images.
2540-- (lib)tiff FAX compression an PS /CCITTFaxEncode have black and white the
2541   opposite way. So `/CCITTFaxEncode <</BlackIs1 true>>' has to be applied
2542   when creating a TIFF file.
2543-- libtiff 3.5.4 doesn't read or write an indexed image with transparency:
2544   Sorry, can not handle contiguous data with PhotometricInterpretation=1,
2545   and Samples/pixel=2. (Doesn't work with convert or GIMP.)
2546-- libtiff 3.5.4 doesn't read or write a gray with transparency:
2547   Sorry, can not handle contiguous data with PhotometricInterpretation=2,
2548   and Samples/pixel=2. (Doesn't work with convert, works with GIMP.)
2549-- libtiff doesn't read or write TIFFTAG_SUBFILETYPE/FILETYPE_MASK +
2550   TIFFTAG_PHOTOMETRIC/PHOTOMETRIC_MASK. One has to use TIFFTAG_EXTRASAMPLES
2551   instead.
2552-- libtiff (and the TIFF file format) supports only /Predictor 1 and
2553   /Predictor 2, with /Compression/LZW and /Compression/ZIP.
2554-- libtiff supports only bpc=8 and bpc=16 with /Predictor 2
2555-- libtiff and most TIFF-handling utils have buggy support for TIFF/JPEG.
2556   See FAQ answer Q4.
2557-- libtiff supports only files with all components having the same
2558   BitsPerSample.
2559-- acroread 4.0 can display all possible /Predictor values with /Indexed1.
2560-- Ghostscript 5.50 renders (PDF?) images inaccurately: the last bit of
2561   the 8-bit palette sometimes gets wrong.
2562-- Netscape Navigator 4.7 displays transparent PNG images with their bKGD
2563   (or an arbitrary color if bKGD not present) as a solid background. This
2564   is a bug.
2565-- pdftops 0.92 has serious problems displaying images if /Predictor != 1.
2566   The image will be obscured without an error message. Ghostscript 5.50 and
2567   Acrobat Reader 4 do not have such problems.
2568-- Ghostscript 5.50 cannot display a PDF with /ColorSpace[/Indexed/DeviceRGB
2569   ...]. Acrobat Reader 4, Ghostscript 7.04 and pdftops 0.92 can.
2570-- /Decode is not required in PDF.
2571-- GIMP 1.0 completely ignores the PNG tRNS chunk! (Thus it won't recognise
2572   such a transparency in PNG.) Use `pngtopnm -alpha' instead!
2573-- pngtopnm honors the PNG bKGD chunk only if called as `pngtopnm -mix'
2574   (and does mixing)
2575-- convert honors the PNG bKGD chunk (and does mixing)
2576-- display doesn't honor the PNG bKGD chunk, but has `-bg' command line option
2577-- xv honors the PNG bKGD chunk (and does mixing)
2578-- PDF procsets (subsection 8.1 of PDFRef.pdf)
2579   /PDF
2580   /Text
2581   /ImageB Grayscale images or image masks
2582   /ImageC Color images
2583   /ImageI Indexed (color-table) images
2584-- Ghostscript always requires the /Decode entry in image dicts
2585-- /DCTEncode and /DCTDecode supports only BitsPerComponent==8.
2586-- Actually PostScript supports 1,2,4,8,12 BitsPerComponent. PDF1.3 supports
2587   only 1,2,4,8. We support only 1, 2, 4 and 8.
2588-- PostScript also supports the CMYK color space, not just gray and RGB.
2589   (And also the HSB, which can be transformed to RGB in an ugly way.)
2590-- PostScript supports PNG predictors to enhance compression.
2591-- The PLRM 4.10.6 describes a trick with patterns and imagemask to do
2592   transparent images. Unfortunately this doesn't work in Ghostscript 5.50
2593   and xpdf 0.92 (but it works in acroread 4.0), so we don't use it. That's
2594   why we have only two *-transparent-* entries.
2595-- ImageMagick EPSI is an EPS with preview (%%BeginPreview .. %%EndPreview)
2596-- ImageMagick EPSF and EPS are equivalent
2597-- ImageMagick EPS* is incredibly slooow because of the bad design, even for
2598   LanguageLevel 2.
2599-- ImageMagick EPS* cannot display color images without the colorimage
2600   opertor. (We could do some trickery with multiple calls to imagemask.)
2601-- tiff2ps cannot display color images without the colorimage
2602   opertor. (We could do some trickery with multiple calls to imagemask.)
2603-- Timing: 1495 x 935 RGB, gs -sDEVICE=bmp16m -sOutputFile=/dev/null
2604   time gs -q -sDEVICE=ppmraw -sOutputFile=t.ppm $IN.eps </dev/null
2605   ImageMagick 6620 ms user
2606   tiff2ps-readhexstring 2320 ms user
2607   currentfile-colorimage 2120 ms user
2608   readstring-colorimage 2170 ms user
2609   currentfile-/FlateDecode-colorimage 2670 ms user
2610-- There is a NullEncode filter, but NullDecode doesn't exist
2611-- speed conclusions:
2612   1. Use currentfile as data source (LanguageLevel2) if possible.
2613   2. /FlateDecode adds a 25% speed penalty. But it compresses quite well,
2614      so use it!
2615-- PostScript LanguageLevel2 supports the indexed color space:
2616
2617        /colormap colors 3 mul string def
2618        currentfile colormap readhexstring pop pop
2619        [ /Indexed /DeviceRGB colors 1 sub colormap ] setcolorspace
2620
2621-- EPS comments: (ImageMagick)
2622
2623        %%DocumentData: Clean7Bit
2624        %%LanguageLevel: 1
2625
2626-- PSL1/PSL2 supports the following color setting operators: (all operands
2627   are between 0.0 and 1.0)
2628
2629        <num> setgray  currentgray % PSL1, 0.0=black 1.0=white
2630        <hue> <saturation> <brightness> sethsbcolor % PSL1
2631        <red> <green> <blue> setrgbcolor % PSL1
2632        <cyan> <magenta> <yellow> <black> setcmykcolor % PSL2; not in PSL1
2633
2634Algorithms, code comments
2635~~~~~~~~~~~~~~~~~~~~~~~~~
2636RGB -> Gray
2637"""""""""""
2638   gray = 0.299*red + 0.587*green + 0.114*blue (NTSC video std)
2639   gray = (306.176*red + 601.088*green + 116.736*blue) >> 10
2640   perl -e 'no integer;for(@ARGV){y/#//d;$N=hex($_);$R=0.299*($N>>16)+0.587*(($N>>8)&255)+0.114*($N&255);print $R/255," ",sprintf("#%02x",int($R+0.5)),"\n"}' '#0f0f0f'
2641 
2642Rgb2 -> Gray
2643""""""""""""
2644   perl -e 'no integer;for(@ARGV){print"$_
2645   ";y/#//d;$N=hex($_);$R=0.299*($N>>16)+0.587*(($N>>8)&255)+0.114*($N&255);
2646   print "",$R/255," ",sprintf("#%02x",int($R+0.5)),"\n"}' 000000 000055 0000aa
2647   0000ff  005500 005555 0055aa 0055ff  00aa00 00aa55 00aaaa 00aaff  00ff00
2648   00ff55 00ffaa 00ffff  550000 550055 5500aa 5500ff  555500 555555 5555aa
2649   5555ff  55aa00 55aa55 55aaaa 55aaff  55ff00 55ff55 55ffaa 55ffff  aa0000
2650   aa0055 aa00aa aa00ff  aa5500 aa5555 aa55aa aa55ff  aaaa00 aaaa55 aaaaaa
2651   aaaaff  aaff00 aaff55 aaffaa aaffff  ff0000 ff0055 ff00aa ff00ff  ff5500
2652   ff5555 ff55aa ff55ff  ffaa00 ffaa55 ffaaaa ffaaff  ffff00 ffff55 ffffaa
2653   ffffff
2654
2655000000 0 #00
2656000055 0.038 #0a
26570000aa 0.076 #13
26580000ff 0.114 #1d
2659005500 0.195666666666667 #32
2660005555 0.233666666666667 #3c
26610055aa 0.271666666666667 #45
26620055ff 0.309666666666667 #4f
266300aa00 0.391333333333333 #64
266400aa55 0.429333333333333 #6d
266500aaaa 0.467333333333333 #77
266600aaff 0.505333333333333 #81
266700ff00 0.587 #96
266800ff55 0.625 #9f
266900ffaa 0.663 #a9
267000ffff 0.701 #b3
2671550000 0.0996666666666667 #19
2672550055 0.137666666666667 #23
26735500aa 0.175666666666667 #2d
26745500ff 0.213666666666667 #36
2675555500 0.295333333333333 #4b
2676555555 0.333333333333333 #55
26775555aa 0.371333333333333 #5f
26785555ff 0.409333333333333 #68
267955aa00 0.491 #7d
268055aa55 0.529 #87
268155aaaa 0.567 #91
268255aaff 0.605 #9a
268355ff00 0.686666666666667 #af
268455ff55 0.724666666666667 #b9
268555ffaa 0.762666666666667 #c2
268655ffff 0.800666666666667 #cc
2687aa0000 0.199333333333333 #33
2688aa0055 0.237333333333333 #3d
2689aa00aa 0.275333333333333 #46
2690aa00ff 0.313333333333333 #50
2691aa5500 0.395 #65
2692aa5555 0.433 #6e
2693aa55aa 0.471 #78
2694aa55ff 0.509 #82
2695aaaa00 0.590666666666667 #97
2696aaaa55 0.628666666666667 #a0
2697aaaaaa 0.666666666666667 #aa
2698aaaaff 0.704666666666667 #b4
2699aaff00 0.786333333333333 #c9
2700aaff55 0.824333333333333 #d2
2701aaffaa 0.862333333333333 #dc
2702aaffff 0.900333333333333 #e6
2703ff0000 0.299 #4c
2704ff0055 0.337 #56
2705ff00aa 0.375 #60
2706ff00ff 0.413 #69
2707ff5500 0.494666666666667 #7e
2708ff5555 0.532666666666667 #88
2709ff55aa 0.570666666666667 #92
2710ff55ff 0.608666666666667 #9b
2711ffaa00 0.690333333333333 #b0
2712ffaa55 0.728333333333333 #ba
2713ffaaaa 0.766333333333333 #c3
2714ffaaff 0.804333333333333 #cd
2715ffff00 0.886 #e2
2716ffff55 0.924 #ec
2717ffffaa 0.962 #f5
2718ffffff 1 #ff
2719
2720Building the palette for Paletted image -> PSLC colorimage
2721""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
2722{ Buf3 0 0 currentfile Bufx readstring pop
2723  % /i 0 def
2724  % Stack: Buf3 0 0 Bufx
2725  { % Stack: Buf3 <Buf3-dst-i> <0-1-2> <byte-read>
2726    exch
2727    { { % Stack: Buf3 <Buf3-dst-i> <byte-read>
2728        dup -2 bitshift Pal exch get
2729        % Stack: Buf3 <Buf3-dst-i> <byte-read> <byte-to-write>
2730        exch 4 bitshift /Carry exch def
2731        % Stack: Buf3 <Buf3-dst-i> <byte-to-write>
2732        3 copy put  pop 1 add  1
2733        % Stack: Buf3 <Buf3-dst-i+1> 1
2734      }{dup -4 bitshift Carry add Pal exch get
2735        exch 15 and 2 bitshift /Carry exch def
2736        3 copy put  pop 1 add  2
2737      }{dup -6 bitshift Carry add Pal exch get
2738        % Stack: Buf3 <Buf3-dst-i> <byte-read> <byte-to-write-first>
2739        exch 4 copy
2740        % Stack: Buf3 <Buf3-dst-i> <byte-to-write-first> <byte-read>  Buf3 <Buf3-dst-i> <byte-to-write-first> <byte-read>
2741        pop put
2742        % Stack: Buf3 <Buf3-dst-i> <byte-to-write-first> <byte-read>
2743        63 and Pal exch get  pop
2744        % Stack: Buf3 <Buf3-dst-i> <byte-to-write-second>
2745        exch 1 add exch
2746        3 copy put  pop 1 add  0
2747        % Stack: Buf3 <Buf3-dst-i+2> 0
2748      }
2749    } exch
2750    % Stack: Buf3 <Buf3-dst-i> <byte-read> {code3} <0-1-2>
2751    get exec
2752    % Stack: Buf3 <Buf3-dst-i++> <1-2-0>
2753  } forall
2754  % Stack: Buf3 <i>
2755  pop pop
2756  Bufr
2757}
2758
2759Color space conversion: (unfinished)
2760""""""""""""""""""""""""""""""""""""
2761-- Ripped from jccolor.c from libjpeg:
2762
2763   * YCbCr is defined per CCIR 601-1, except that Cb and Cr are
2764   * normalized to the range 0..MAXJSAMPLE rather than -0.5 .. 0.5.
2765   * The conversion equations to be implemented are therefore
2766   *      Y  =  0.29900 * R + 0.58700 * G + 0.11400 * B
2767   *      Cb = -0.16874 * R - 0.33126 * G + 0.50000 * B  + CENTERJSAMPLE
2768   *      Cr =  0.50000 * R - 0.41869 * G - 0.08131 * B  + CENTERJSAMPLE
2769   * (These numbers are derived from TIFF 6.0 section 21, dated 3-June-92.)
2770
2771
2772
2773   -- RGB -> YCbCr:
2774          Y  =  0.29900 * R + 0.58700 * G + 0.11400 * B
2775          Cb = -0.16874 * R - 0.33126 * G + 0.50000 * B  + CENTERJSAMPLE
2776          Cr =  0.50000 * R - 0.41869 * G - 0.08131 * B  + CENTERJSAMPLE
2777   -- CMYK -> YCCK:
2778          R=1-C, G=1-M, B=1-Y, K=K, RGB -> YCbCr
2779   -- YCbCr -> RGB: (Cb < CENTERJSAMPLE, Cr < CENTERJSAMPLE)
2780          R = Y                + 1.40200 * Cr
2781          G = Y - 0.34414 * Cb - 0.71414 * Cr
2782          B = Y + 1.77200 * Cb
2783   -- YCCK -> CMYK:
2784          YCbCr -> RGB, C=1-R, M=1-G, Y=1-B, K=K.
2785   -- (YCbCrK == YCCK)
2786   -- Gray -> RGB: red = gray, green = gray, blue = gray
2787   -- RGB -> Gray: gray = 0.299*red + 0.587*green + 0.114*blue (NTSC video std)
2788                 : gray = (306.176*red + 601.088*green + 116.736*blue) >> 10
2789                 : gray = (19595.264*red + 38469.632*green + 7471.104*blue) >> 16
2790   -- Obsolete: RGB -> YCbCr: (YCbCr == YUV)
2791        y:luminance = 0.299*red + 0.587*green + 0.114*blue (0..1)
2792        cb:chrominance-b = blue - y = - 0.299*red - 0.587*green + 0.886*blue  (-0.886 .. 0.886)
2793        cr:chrominance-r = red - y = 0.701*red - 0.587*green - 0.114*blue (-0.701 .. 0.701)
2794      Chrominance components can be represented less accurately since the
2795      human eye is around twice as sensitive to luminance as to chrominance.
2796   -- RGB <-> HSB: quite obfuscated. See gshsb.c in Aladdin Ghostscript's
2797      source.
2798
2799Word frequency counting in PostScript source
2800""""""""""""""""""""""""""""""""""""""""""""
2801perl -e '$C=0; $X=join"",<STDIN>; for (split" ",$X) { print "$_.\n";
2802$C+=length($_)-1 if /[0-9]/ }; print STDERR "C=$C\n"'
2803
2804</tmp/t perl -e '$C=0; $X=join"",<STDIN>; $X=~s@([{}])@ $1 @g; $X=~s@/@ /@g;
2805for (split" ",$X) { print "$_.\n" if length>=2; $C++ if length($_)>=2 };
2806print STDERR "C=$C\n"' | sort | uniq
2807
2808</tmp/t perl -e '$C=0; $X=join"",<STDIN>; $X=~s@([{}])@ $1 @g; $X=~s@/@ /@g;
2809$Y=""; for (split" ",$X) { $_=" $_ " if length($_)>=2; $Y.=$_ }; $Y=~s@
2810/@/@g; print $Y' >t
2811
2812How tiff2ps displays a gray version of a PSLC Rgb8 image on PSL1
2813""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
2814gsave
2815100 dict begin
28161495.000000 935.000000 scale
2817/bwproc {
2818    rgbproc
2819    dup length 3 idiv string 0 3 0
2820    5 -1 roll {
2821        add 2 1 roll 1 sub dup 0 eq {
2822            pop 3 idiv
2823            3 -1 roll
2824            dup 4 -1 roll
2825            dup 3 1 roll
2826            5 -1 roll put
2827            1 add 3 0
2828        } { 2 1 roll } ifelse
2829    } forall
2830    pop pop pop
2831} def
2832/colorimage where {pop} {
2833    /colorimage {pop pop /rgbproc exch def {bwproc} image} bind def
2834} ifelse
2835%ImageData: 1495 935 8 3 0 1 2 "false 3 colorimage"
2836/line 4485 string def
28371495 935 8
2838[1495 0 0 -935 0 935]
2839{currentfile line readhexstring pop} bind
2840false 3 colorimage
2841
2842pts_defl.c which function calls which function
2843""""""""""""""""""""""""""""""""""""""""""""""
2844send_bits
2845  rengeteg
2846flush_outbuf
2847  send_bits
2848  flush_block 2*
2849build_tree
2850  flush_block 3*
2851flush_block
2852  deflate2 5*
2853ct_tally
2854  deflate2 sok*
2855longest_match
2856  deflate2 2*
2857fill_window
2858  deflate2 4*
2859
2860gen_codes
2861  2, reentrant
2862deflate2
2863  1..
2864pts_deflate_init
2865  1
2866
2867Answers from Taco
2868"""""""""""""""""
2869Are the problems I'm concerned about already solved?
2870
2871   -- Is there a pixel image converter that can create small and compatible
2872      EPS documents with all the RunLength, CCITTFax, LZW and Flate
2873      compression types?
2874
2875   -- Is there a PDF version of psfrag.sty? Is there a utility for splitting
2876      and assebling PDF files? Is there a utility for changing text labels
2877      inside a PDF file?
2878
2879   -- Is there a utility for creating (semi-)transparent EPS or PDF files
2880      from pixel images?
2881
2882Compilation problems
2883""""""""""""""""""""
2884-- Mårten Svantesson wrote:
2885
2886  > Another problem was that the configure script didn't realise that it
2887  > couldn't use the forte CC-compiler. This lead to several errors. For
2888  > example it doesn't accept the option -ansi, so several tests fail for
2889  > this reason.
2890
2891  I don't have access to the a forte CC-compiler. The configure script has
2892  been designed for use with GCC and G++.
2893
2894-- Peter Dyballa wrote (unquoted):
2895
2896    > > leads to PTS_lstat being #define'd as lstat -- while stat would be correct.
2897    >
2898    > Why do you think that stat would be correct?
2899
2900    Because /usr/include/sys/stat.h contains this:
2901
2902            __BEGIN_DECLS
2903            int     chmod __P((const char *, mode_t));
2904            int     fstat __P((int, struct stat *));
2905            int     mkdir __P((const char *, mode_t));
2906            int     mkfifo __P((const char *, mode_t));
2907            int     stat __P((const char *, struct stat *));
2908            mode_t  umask __P((mode_t));
2909            #ifndef _POSIX_SOURCE
2910            int     chflags __P((const char *, u_long));
2911            int     fchflags __P((int, u_long));
2912            int     fchmod __P((int, mode_t));
2913            int     lstat __P((const char *, struct stat *));
2914            #endif
2915            __END_DECLS
2916
2917    and gensio.cpp #define's _POSIX_SOURCE.
2918
2919    >  I think that that PTS_lstat is defined as it should, but configure should generate the poper condition for #if. Please submit a patch to configure.
2920    >
2921
2922    This makes it compile in Mac OS X 10.3.9 (Panther):
2923
2924    diff -Naur gensio.cpp~ gensio.cpp
2925    --- gensio.cpp~ Thu Mar  3 23:00:06 2005
2926    +++ gensio.cpp  Mon Oct 31 15:07:53 2005
2927    @@ -16,7 +16,9 @@
2928     #else
2929     #undef __STRICT_ANSI__ /* for __MINGW32__ */
2930     #define _BSD_SOURCE 1 /* vsnprintf(); may be emulated with fixup_vsnprintf() */
2931    +#ifndef __APPLE__
2932     #define _POSIX_SOURCE 1 /* also popen() */
2933    +#endif
2934     #define _POSIX_C_SOURCE 2 /* also popen() */
2935     #define _XOPEN_SOURCE_EXTENDED 1 /* Digital UNIX lstat */
2936     #ifndef _XPG4_2
2937
2938   ---
2939
2940   I've integrated his #ifndef __APPLE__ patch. There should be a better way
2941   to handle this situation, though.
2942
2943-- How to compile with i386-uclibc-gcc on Debian Etch:
2944
2945   by pts@fazekas.hu at Sun Apr  5 00:28:53 CEST 2009
2946
2947   $ i386-uclibc-gcc -v
2948   Invoked as i386-uclibc-gcc
2949   arg[ 0] = gcc
2950   arg[ 1] = -v
2951   Using built-in specs.
2952   Target: i486-linux-gnu
2953   Configured with: ../src/configure -v --enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --enable-nls --program-suffix=-4.1 --enable-__cxa_atexit --enable-clocale=gnu --enable-libstdcxx-debug --enable-mpfr --with-tune=i686 --enable-checking=release i486-linux-gnu
2954   Thread model: posix
2955   gcc version 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)
2956   $ CXX='i386-uclibc-gcc -static' CC=i386-uclibc-gcc ./configure --enable-gif --enable-lzw
2957   # change LDXX=... to LDXX=$(CXX) in Makehelp
2958   $ make
2959   # (Unfortunately, the executable is large, 410KB)
2960
2961
2962Revision history, changes
2963~~~~~~~~~~~~~~~~~~~~~~~~~
2964See in the file debian/changelog.
2965
2966Missing feature list
2967~~~~~~~~~~~~~~~~~~~~
2968!! make mkdist-noautoconf creates .tar.gz w/o leading directory part
2969!! cannot read t.pnm "P4 1 1 1" doesn't end with \S
2970!! ./sam2p ../pts.ppm t.gif -> sam2p: out_gif.cpp:260: void out_gif_write(GenBuffer::Writable&, Image::Indexed*): Assertion `bits_per_pixel<=8' failed.
2971!! why so large PNG? sam2p examples/chessboard_ascii.pnm t.png
2972!! easy seek back to 0 in in_*.cpp
2973!! rxvt_bug.png -> useful Win98 .bmp
2974??
2975     (expected) !!
2976     --invert option, for tif22pnm users
2977     complete turbo tutorial,
2978     MIFF input, _output_
2979     full BMP output compressed,
2980     faster GIF input??, make install, .deb (debhelper?), .rpm,
2981     normal `image' instead of `colorimage'
2982     CUPS raster input and output,
2983     /Background option (-bg) to change transparent pixels -> bg color
2984     LZW and ZIP compressed for indexed etc.
2985/* OK : PS and PDF input */
2986/* Imp: parse bts2.ttt just after generating (balance of [ << ... >> ])
2987/* Imp: command line option for /Transparent */
2988/* Imp: avoid 3 warnings in: ./sam2p examples/pts2.pbm t.ppm */
2989/* OK : margins for all PS, EPS and PDF (Sat Sep  7 16:17:58 CEST 2002 */
2990/* Imp: howto in pts_defl.h */
2991/* Imp: check for fixed bugs new zlib */
2992/* OK : built-in CCITTFaxEncode */
2993/* Imp: one-liner eliminate automatically invalid BMP SampleFormats with compression */
2994/* OK : more transferencodings for l1fa85g.tte */
2995/* Imp: eliminate long line (>120) from l1fa85g.tte */
2996/* Imp: one-liner -s gray|indexed|rgb|transparent */
2997/* OK : read bad.txt, and move it to section {Fixed bugs} */
2998/* OK : verify /Compression/Fax /K 1|2 with gs 5.50|7.04 */
2999/* Imp: in-memory dump when scanf_dict Error */
3000/* Imp: optimal, non-mem-hungry RLE compression filter (hardly possible...) */
3001/* Imp: possibility to write RGB (non-YCbCr) JPEG with /Compression/IJG etc. */
3002/* Imp: ability to load .gz and .zip compressed input files. Example:
3003 * .pbm.gz
3004 */
3005/* Imp: no return DONT_KNOW from *_work() */
3006/* Imp: Meta output */
3007/* Imp: PSL1 auto fallback to grayscale `image' in absence of `colorimage' */
3008/* Imp: full support for ZIP compression in PSL1 (similar to RLE) */
3009/* OK:  TIFF output */
3010/* Imp: implement as a library (throw/catch exceptions, memory management, reentrance) */
3011/* Imp: check for proper inner dict usage in l1fa85g.tte */
3012/* Imp: add /Transparent2, /Transparent4, /Transparent8 for PDF */
3013/* Imp: add all #warning REQUIRES: */
3014/* OK : ccdep.pl, --enable-debug (Sat Jun  1 16:27:58 CEST 2002) */
3015/* Imp: show binary/ASCII in PDF and PS header comments */
3016/* Imp: `available loaders: (TIFF)' if tifftopnm not found (run-time) */
3017/* Imp: make LZW-unsupported not an Error, but a Warning */
3018/* Imp: create output profile */
3019/* OK:  a real string hashing lib */
3020/* Imp: GIF reader is too slow (maybe LZW reading? ?). Change to xvgif.c?? */
3021/* OK : XPM reader (>=256 colors) is too slow */
3022/* OK : specify transparent color in the Job file */
3023/* Imp: run-time detect the absence of external progs */
3024/* Imp: make install */
3025/* Imp: make .deb, .rpm */
3026/* No : NDEBUG by default */
3027/* Imp: substitute char (1) for bool (8) on Digital UNIX */
3028/* OK : real replacement of vsnprintf() (Digital UNIX, Solaris) -- Tue Jun 11 15:20:22 CEST 2002 */
3029/* OK : close both filters in l23.tte, but _never_ close currentfile */
3030/* Imp: run-time choice from FlateEncode filter implemenetations etc. */
3031/* Imp: convert bilevel indexed image to grayscale more quickly */
3032/* OK : add quick and effective command line interface (one-liner mode) */
3033/* No : read external .tte files (runtime) instead of built-in .tth */
3034/* Imp: possibility to store several profiles in the same .jib file */
3035/* Imp: real, PDF-style dates into Created, Produced */
3036/* OK : real hashing in MiniPS::Dict */
3037/* Imp: enforce magic numbers for .job and .jib files */
3038/* OK : /TransferEncoding: * -> ascii if ... */
3039/* Imp: (early check, special handler) make everything work when wd==0 || ht==0; especially encoding filters */
3040/* Imp: better Job option for specifying and removing transparent color (better than /Transparent) */
3041/* Imp: log date(now) */
3042/* OK : DCT options in Output Rule */
3043/* OK : implement JAI */
3044/* Imp: support LargeBBox */
3045/* Imp: support Comment */
3046/* Imp: support PDF metadata: Title Subject Author Creator Producer */
3047/* Imp: support PDF dates: Created Produced */
3048/* Imp: support Comment */
3049/* Imp: add PAM file format support from NetPBM */
3050/* OK : verify ADSC EPSF-3.0 compatibility */
3051/* Imp: pre-transformation: making grayscale */
3052/* Imp: pre-transformation: down-bit-sampling */
3053/* Imp: pre-transformation: down-palette-sampling (``generate optimal palette'') */
3054/* Imp: tif22pnm warning - non-square pixels; to fix do a 'pnmscale -yscale nan'P6 2840 2138 255 */
3055==6750==
3056==6750== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
3057==6750== malloc/free: in use at exit: 3741 bytes in 102 blocks.
3058==6750== malloc/free: 2296 allocs, 2194 frees, 170451 bytes allocated.
3059==6750== For counts of detected errors, rerun with: -v
3060==6750== searching for pointers to 102 not-freed blocks.
3061==6750== checked 4227304 bytes.
3062==6750==
3063==6750== 12 bytes in 1 blocks are definitely lost in loss record 3 of 15
3064==6750==    at 0x400254FF: __builtin_new (vg_replace_malloc.c:172)
3065==6750==    by 0x806ABC3: MiniPS::Parser::parse1(int, int) (minips.cpp:789)
3066==6750==    by 0x806B378: MiniPS::Parser::parse1(int, int) (minips.cpp:856)
3067==6750==    by 0x804DBD5: run_sam2p_engine(Files::FILEW &, Files::FILEW &, char const *const *, bool) (sam2p_main.cpp:923)
3068==6750==
3069==6750==
3070==6750== 808 bytes in 81 blocks are possibly lost in loss record 14 of 15
3071==6750==    at 0x400255E9: __builtin_vec_new (vg_replace_malloc.c:197)
3072==6750==    by 0x8060C94: Mapping::DoubleHash::set(char const *, unsigned int, char const *) (mapping.cpp:43)
3073==6750==    by 0x806A18B: MiniPS::Dict::put(char const *, unsigned int, int) (minips.cpp:461)
3074==6750==    by 0x8069FF1: MiniPS::Dict::put(char const *, int) (minips.cpp:431)
3075==6750==
3076==6750== LEAK SUMMARY:
3077==6750==    definitely lost: 12 bytes in 1 blocks.
3078==6750==    possibly lost:   808 bytes in 81 blocks.
3079==6750==    still reachable: 2921 bytes in 20 blocks.
3080==6750==         suppressed: 0 bytes in 0 blocks.
3081
3082Known bugs
3083~~~~~~~~~~
3084(reported by Stefan Fritsch)
3085
3086> I got a bug report [1] about sam2p 0.44-10 not including a length
3087> after the %%BeginData: line. As I understand it, the length is not
3088> optional (see [2] p.44 (and gsview output?)). Sam2p 0.44-11 adds a
3089> ";" after to this line. What does this ";" do? Is this supposed to be
3090> conforming to the postscript standard? If not, are you planning to
3091> write a real fix?
3092>
3093> [1] http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=315046
3094> [2] http://partners.adobe.com/public/developer/en/ps/5001.DSC_Spec.pdf
3095
3096Fixing it would require a major rewrite.
3097However, I don't have free time for that right now. If you really care about
3098standards, remove the %%BeginData...%%EndData pair from the
3099PostScript file or remove it altogether from the sam2p sources. The `;' is
3100there so GSView won't complain.
3101
3102!! compiling on Debian SID with uclibc-toolchain
3103   i386-uclibc-linux-g++, the statically linked sam2p executable becomes
3104   quite biiiig: 668268 bytes.
3105   for configure: export CXX='i386-uclibc-linux-gcc -x c++ -static'
3106   Also, Makehelp has to be modified after running configure:
3107   LDXX=i386-uclibc-linux-g++ -static
3108
3109!! .eps import bad shift of BBX (LLX,LLY) with never Ghostscript
3110
3111Fixed bugs
3112~~~~~~~~~~
3113(this section was formerly bad.txt)
3114
3115./sam2p -j examples/ptsbanner2.jpg test.pdf
3116  discover at Sun Sep 22 14:38:39 CEST 2002
3117  BUGFIX at Sun Sep 22 15:03:33 CEST 2002
3118
3119./sam2p -1 -s:rgb1 -c:none examples/pts2.pbm test.eps
3120  discover at Sun Sep 22 14:29:59 CEST 2002
3121  BUGFIX (add -s:...:stopq) at Sun Sep 22 16:20:41 CEST 2002
3122  (behaviour correct, specifying -s:rgb1:stop gives more error messages)
3123
3124./sam2p -c:fax:2 examples/shot.gif y.pdf
3125  BUGFIX /EndOfLine true is forced
3126  old gs: /ioerror in --%image_file_continue--
3127  old acroread: `read less image data' (PDFB1.0: `expected EI')
3128./sam2p -c:fax:1 examples/shot.gif y.pdf
3129  BUGFIX /EndOfLine true is forced
3130  gs: OK
3131  old acroread: `read less image data' (PDFB1.0: `problem 115')
3132./sam2p -c:fax:0 examples/shot.gif y.pdf
3133  gs, acroread: OK
3134./sam2p -c:fax:-1 examples/shot.gif y.pdf
3135  gs, acroread: OK
3136
3137./sam2p -c:fax examples/pts2.pbm y.tiff
3138  BUGFIX black-white inversion
3139./sam2p -c:fax examples/shot.gif y.tiff
3140  BUGFIX black-white inversion
3141
3142./sam2p -j -c jpeg examples/pts2.pbm y.tiff
3143  seems to be OK now
3144./sam2p -j -c jpeg examples/pts2.pbm y.tiff
3145  seems to be OK now
3146
3147./sam2p -j -c fax examples/ptsbanner.gif y.eps
3148  BUGFIX guard against applying /Compression/Fax to non-1-bit data
3149./sam2p -j -c fax -s:Indexed8 examples/ptsbanner.gif y.eps
3150  OK, no guard
3151./sam2p -j -c fax -c none examples/ptsbanner.gif y.eps
3152  OK, no guard
3153./sam2p -j -c fax examples/ptsbanner.gif y.tiff
3154  BUGFIX forbidden applying /Compression/Fax to non-1-bit data
3155
3156./sam2p -c fax csanyi_torok_old.png csanyi_torok.eps
3157./sam2p -c fax examples/ptsbanner.gif csanyi_torok.eps
3158  error: Impossible combination
3159  OK, the user should specify `-s Indexed8' for unexpected use of  `-c fax'
3160
3161__END__