summaryrefslogtreecommitdiff
path: root/support/pstools
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /support/pstools
Initial commit
Diffstat (limited to 'support/pstools')
-rw-r--r--support/pstools/cep/0cep_lic.eng48
-rw-r--r--support/pstools/cep/0cep_lic.pol50
-rw-r--r--support/pstools/cep/cep.awk205
-rw-r--r--support/pstools/cep/cep.bat48
-rw-r--r--support/pstools/cep/cepcop_e.inf371
-rw-r--r--support/pstools/cep/cepcop_p.inf478
-rw-r--r--support/pstools/cep/cop.awk143
-rw-r--r--support/pstools/cep/cop.bat49
-rw-r--r--support/pstools/cep/uncep.awk140
-rw-r--r--support/pstools/cep/uncep.bat31
-rw-r--r--support/pstools/cep/uncop.awk103
-rw-r--r--support/pstools/cep/uncop.bat31
-rw-r--r--support/pstools/ps_conv/0ps_conv.doc92
l---------support/pstools/ps_conv/README1
-rw-r--r--support/pstools/ps_conv/gc.bat29
-rw-r--r--support/pstools/ps_conv/gc.par1
-rw-r--r--support/pstools/ps_conv/gc_head.ps32
-rw-r--r--support/pstools/ps_conv/gc_tail.ps4
-rw-r--r--support/pstools/ps_conv/ps_conv.ps286
-rw-r--r--support/pstools/tif2eps/readme.eng53
-rw-r--r--support/pstools/tif2eps/readme.pol57
-rwxr-xr-xsupport/pstools/tif2eps/tif2eps4
-rw-r--r--support/pstools/tif2eps/tif2eps.bat7
-rw-r--r--support/pstools/tif2eps/tif2eps.ps2246
24 files changed, 4509 insertions, 0 deletions
diff --git a/support/pstools/cep/0cep_lic.eng b/support/pstools/cep/0cep_lic.eng
new file mode 100644
index 0000000000..87dba7dcce
--- /dev/null
+++ b/support/pstools/cep/0cep_lic.eng
@@ -0,0 +1,48 @@
+ This file belongs to the CEP package | Ten plik nale/zy do pakietu CEP
+ This package is public domain | Pakiet stanowi dobro powszechne
+========================================================================
+
+CEP package consists of:
+ Info files:
+ 0CEP_LIC.ENG -- English license (This file)
+ 0CEP_LIC.POL -- Polish license
+ CEPCOP_E.INF -- English documentation
+ CEPCOP_P.INF -- Polish documentation
+ CEP subpackage:
+ CEP.AWK -- CEP compression program
+ CEP.BAT -- MSDOS system script for CEP.AWK
+ UNCEP.AWK -- CEP uncompression program
+ UNCEP.BAT -- MSDOS system script for UNCEP.AWK
+ COP subpackage:
+ COP.AWK -- COP compression program
+ COP.BAT -- MSDOS system script for COP.AWK
+ UNCOP.AWK -- COP uncompression program
+ UNCOP.BAT -- MSDOS system script for UNCOP.AWK
+
+=======================================================================
+
+AUTHORS: Bogu\l{}aw Jackowski, Piotr Pianowski, Piotr Strzelczyk
+Mail: BOP s.c., ul. Piastowska 70, 80-363 Gda\'nsk, Poland
+Email: B.Jackowski@GUST.org.pl
+
+=======================================================================
+
+All copyrights, copylefts, copyups, copydowns, or whatever you wish to call
+them, concerning all the files in the CEP package are essentially of the
+public domain character.
+
+This package is distributed in the hope that it will be useful, but without
+any warranty. Although the authors have attempted to find and correct any bugs
+in the package, they are not responsible for any damage or losses of any kind
+caused by the use or misuse of the package. The authors are under no
+obligation to provide service, corrections, or upgrades to this package.
+
+If you alter a file or if you distrubute incomplete package,
+please remove the lines containing the comment:
+
+ `This file belongs to the CEP package | Ten plik nale/zy do pakietu CEP'
+
+in order to avoid mess.
+
+=======================================================================
+END OF `0CEP_LIC.ENG'
diff --git a/support/pstools/cep/0cep_lic.pol b/support/pstools/cep/0cep_lic.pol
new file mode 100644
index 0000000000..46359e284d
--- /dev/null
+++ b/support/pstools/cep/0cep_lic.pol
@@ -0,0 +1,50 @@
+ This file belongs to the CEP package | Ten plik nale/zy do pakietu CEP
+ This package is public domain | Pakiet stanowi dobro powszechne
+========================================================================
+
+Pakiet CEP sk/lada si/e z:
+ Plik/ow informacyjnych:
+ 0CEP_LIC.ENG -- Licencja w j/ezyku angielskim
+ 0CEP_LIC.POL -- Licencja w j/ezyku polskim (niniejszy plik)
+ CEPCOP_E.INF -- Angielska dokumentacja
+ CEPCOP_P.INF -- Polska dokumentacja
+ Podpakietu CEP:
+ CEP.AWK -- program kompresuj/acy CEP
+ CEP.BAT -- skrypt wsadowy uruchamiaj/acy CEP.AWK
+ UNCEP.AWK -- program dekompresuj/acy pliki CEP-a
+ UNCEP.BAT -- skrypt wsadowy uruchamiaj/acy UNCEP.AWK
+ Podpakietu COP:
+ COP.AWK -- program kompresuj/acy COP
+ COP.BAT -- skrypt wsadowy uruchamiaj/acy COP.AWK
+ UNCOP.AWK -- program dekompresuj/acy pliki COP-a
+ UNCOP.BAT -- skrypt wsadowy uruchamiaj/acy UNCOP.AWK
+
+=======================================================================
+
+AUTORZY: Bogus/law Jackowski, Piotr Pianowski, Piotr Strzelczyk
+Adres: BOP s.c., ul. Piastowska 70, 80-363 Gda/nsk, Poland
+Email: B.Jackowski@GUST.org.pl
+
+=======================================================================
+
+Wszystkie prawa, lewa, g/ory, do/ly autorskie, czy jak tam to zwa/c,
+dotycz/ace wszystkich plik/ow wchodz/acych w sk/lad pakietu CEP,
+maj/a charakter dobra publicznego.
+
+Rozpowszechniaj/ac ten pakiet mamy nadziej/e, /ze oka/ze si/e on przydatny,
+nie dajemy jednak na niego /zadnej gwarancji. Starali/smy si/e znale/x/c
+i usun/a/c z pakietu wszystkie b/l/edy, ale nie ponosimy /zadnej
+odpowiedzialno/sci za uszkodzenia b/ad/x straty wywo/lane jego w/la/sciwym
+lub niew/la/sciwym u/zyciem. Jednocze/snie zaznaczamy, /ze o ile b/edziemy
+starali si/e piel/egnowa/c pakiet, o tyle nie nie podejmujemy /zadnych
+zobowi/aza/n w tej mierze.
+
+Je/zeli plik zosta/l zmodyfikowany lub rozpowszechniana jest tylko cz/e/s/c
+pakietu, prosimy o usuni/ecie linii zawieraj/acych komentarz:
+
+ ,,This file belongs to the CEP package | Ten plik nale/zy do pakietu CEP''
+
+w celu unikni/ecia ba/laganu.
+
+=======================================================================
+KONIEC ,,0CEP_LIC.POL''
diff --git a/support/pstools/cep/cep.awk b/support/pstools/cep/cep.awk
new file mode 100644
index 0000000000..7360796e4b
--- /dev/null
+++ b/support/pstools/cep/cep.awk
@@ -0,0 +1,205 @@
+# This file belongs to the CEP package | Ten plik nale/zy do pakietu CEP
+# This package is public domain | Pakiet stanowi dobro powszechne
+# For more info see `0CEP_LIC.ENG' | Wi/ecej informacji w ,,0CEP_LIC.POL''
+# ===========================================================================
+# E: "Hex bitmap EPS" --> "filtered EPS" converter
+# input - input file name
+# OUTF - output file name
+# CVM - conversion method
+# TMPSX - temporary PostScript file name
+#
+# P: Konwerter "Hex bitmap EPS" --> "filtered EPS"
+# wej/scie - nazwa pliku konwertowanego
+# OUTF - nazwa pliku wyj/sciowego
+# CVM - metoda konwersji EPS-a
+# TMPSX - nazwa tymczasowego pliku PostScriptowego
+
+BEGIN {
+ ver_no=1.03
+ gs_abort="2 2 .quit"
+ RS="\015|\012|\015\012"
+ # preparing temporary files | przygotowywanie plik/ow tymczasowych
+ if (TMPSX=="") TMPSX="tmp.psx"
+ if (CVM!~/[LlRrFfNn]/) CVM=CVM "R" # Default coding and compression method
+ if (CVM!~/[Hh8]/) CVM=CVM "8" # Domy/slna metoda kodowania i kompresji
+ printf "CEP ver. " ver_no ", Coding:"
+ if (is_A85()) printf " A85"
+ if (is_HEX()) printf " Hex"
+ if (is_LZW()) printf ", LZW"
+ if (is_RLE()) printf ", RLE"
+ if (is_ZIP()) printf ", Flate (non-standard in PostScript Level 2!)"
+ print ""
+ flag="pre"
+}
+
+ # searching for ``strange lines'' is due to the following problem:
+ # a single hex char in line or Postscript command "def" and "add" in prolog
+ # may be misunderstood for a HEX bitmap (see also ``heuristic trick'')
+ # poszukiwanie ,,dziwnych wierszy'' wi/a/ze si/e z nast/epuj/acym problemem:
+ # pojedynczy znak w wierszu oraz instrukcje Postscriptu "def" i "add"
+ # stanowi/ace cz/e/s/c prologu mog/a zosta/c b/l/ednie uznane za
+ # fragment szesnastkowej mapy bitowej (patrz ,,heurystyczny fortel'')
+
+{is_hex_line=/^[0-9A-Fa-f]*$/
+ if (flag=="hex") {
+ if (is_hex_line) {hex_dig_num+=length($0)} else {flag="post"; pos_lines++}
+ } else {is_odd_line=/^(def|add|[0-9A-Fa-f]|)$/
+ if (flag=="pre") {
+ if (is_hex_line && !is_odd_line) {flag="hex"; hex_dig_num+=length($0)}
+ else {prolog=prolog $0 "\n"; pre_lines++}
+ } else {
+ if (is_hex_line && !is_odd_line) {flag="xhex"; exit} else {pos_lines++}
+ }
+ }
+}
+
+END {
+ if (flag=="pre") errmessage("HEX bitmap not found.", 1)
+ if (flag=="xhex") errmessage("more than one HEX bitmap's found.", 2)
+
+ # fix (somehow) length of bitmap bufor
+ # ustalanie d/lugo/sci bufora b/ed/acej dzielnikiem d/lugo/sci mapy bitowej
+ if ((hex_dig_num%2)!=0)
+ errmessage("Odd number of HEX digits in the bitmap.", 3)
+ hex_dig_num=hex_dig_num/2
+ buff_len=8192
+ while (hex_dig_num%buff_len!=0) buff_len--
+ buff_num=hex_dig_num/buff_len
+
+ # modification of the preamble of compressed EPS file
+ # dostosowanie preambu/ly pliku EPS do czytania kompresowanych danych
+ if (match(prolog,/\n%%BoundingBox:[^\n]*\n/))
+ prolog = substr(prolog,1,RSTART+RLENGTH-1) banner() "\n" uncep_comment() "\n" substr(prolog,RSTART+RLENGTH)
+ else
+ errmessage("\"%%BoundingBox:\" not found.", 4)
+ if (gsub(/currentfile/,"_fltrd_file",prolog)==0)
+ errmessage("illegible EPS preamble.", 5)
+ if (gsub(/readhexstring/,"_read_string",prolog)==0)
+ errmessage("illegible EPS preamble.", 6)
+ if (match(prolog, /\n[^%\n]/))
+ prolog = substr(prolog,1,RSTART-1) "\n" source() substr(prolog,RSTART)
+ else
+ errmessage("illegible EPS preamble.", 7)
+ # heuristic trick: | heurystyczny fortel:
+ # odd lines at the end of prolog are to be considered as a bitmap beginning
+ # dziwne linie na ko/ncu prologu nale/zy uzna/c za pocz/atek mapy bitowej
+ if (match(prolog,/\n((def|add|[0-9A-Fa-f])\n)+$/)) {
+ prolog = substr(prolog,1,RSTART);
+ print "CEP warning: peculiar bitmap beginning."
+ }
+ gsub(/%/,"%%",prolog) # neutralizing printf | podmiana dla printf
+
+ # WRITE PostScript ENCODING PROGRAM | TWORZENIE PROGRAMU Postscript-owego
+ out_ps_errorhandler()
+ #
+ out_ps("(" ps_fname(OUTF) ") (w) file /w_file exch def")
+ out_ps("(" ps_fname(FILENAME) ") (r) file /r_file exch def")
+ out_ps("/l_string 255 string def")
+ out_ps("/p_string 4096 string def")
+ out_ps("/b_string " buff_len " string def")
+ out_ps("/flushclose {dup flushfile closefile} def")
+ # copy preamble | przepisywanie preambu/ly
+ out_ps(pre_lines " {r_file l_string readline pop pop} repeat")
+ out_ps(pre_lines+3 " {currentfile l_string readline pop")
+ out_ps("w_file exch writestring w_file (\\n) writestring} repeat")
+ out_ps_block(prolog)
+ out_ps("%--- PROLOG END | KONIEC PROLOGU")
+ # special treatment of the ASCII85 encoded lines looking like DSC comments
+ # dodatkowa obr/obka wierszy (zakodowanych jako ASCII85) zaczynaj/acych
+ # si/e tak jak komentarze DSC
+ if (is_A85()) {
+ out_ps("{pop (%) anchorsearch {pop w_file (%\\n ) writestring} if")
+ out_ps(" {(\\n%) search not {exit} if")
+ out_ps(" w_file exch writestring pop w_file (\\n%\\n ) writestring} loop")
+ out_ps(" w_file exch writestring p_string}")
+ out_ps("/NullEncode filter dup")
+ } else out_ps("w_file")
+ # prepare encoding filters | przygotowywanie filtr/ow koduj/acych
+ if (is_A85()) out_ps("/ASCII85Encode filter")
+ if (is_HEX()) out_ps("/ASCIIHexEncode filter")
+ if (is_LZW()) out_ps("dup /LZWEncode filter")
+ if (is_RLE()) out_ps("dup 0 /RunLengthEncode filter")
+ if (is_ZIP()) out_ps("dup /FlateEncode filter")
+ # loop encoding bitmap | p/etla koduj/aca map/e bitow/a
+ out_ps(buff_num " {r_file b_string readhexstring pop")
+ out_ps("1 index exch writestring} repeat")
+ if (is_A85()) out_ps("flushclose flushclose")
+ if (is_HEX()) out_ps("flushclose")
+ if (is_LZW()) out_ps("flushclose")
+ if (is_RLE()) out_ps("flushclose")
+ if (is_ZIP()) out_ps("flushclose")
+ # copy postamble | przepisanie postambu/ly
+ out_ps(pos_lines+1 " {r_file l_string readline pop")
+ out_ps("w_file exch writestring w_file (\\n) writestring} repeat")
+ out_ps("w_file flushclose r_file closefile quit")
+ printf "."
+}
+
+function banner() {return "%%Creator: CEP ver. " ver_no " by BOP s.c."}
+
+function ps_fname(s) {gsub(/\\/,"/",s); return(s)}
+
+function out_ps(s) {print s > TMPSX}
+function out_ps_block(block) {printf block > TMPSX}
+
+function out_ps_errorhandler() {
+ out_ps("/errq {" gs_abort "} def")
+ out_ps("errordict begin ")
+ out_ps("/typecheck {255 string cvs (filter) search")
+ out_ps(" {(\\010!Filter failed) print")
+ out_ps(" ( (ASCII85Encode used with GS version<3.0?)\\n\\007) print}")
+ out_ps(" {(\\010!Something went wrong\\n Error: typecheck\\n\\007) print}")
+ out_ps(" ifelse errq} def")
+ out_ps("/ioerror {(\\010!Input/Output error occurred. (Disk full?)\\n\\007)")
+ out_ps(" print errq} def")
+ out_ps("/handleerror {$error begin (Something went wrong) print")
+ out_ps(" (\\n Error: ) print errorname 255 string cvs print")
+ out_ps(" (\\n\\007) print end errq} def")
+ out_ps("end")
+ #
+ out_ps("systemdict /resourcestatus known not")
+ out_ps("{(\\010!This version of Ghostscript doesn't support required Level 2 features\\n\\007)")
+ out_ps(" print quit} if")
+ if (is_A85()) {
+ check_filter("ASCII85Encode", "ASCII85Encode filter")
+ check_filter("NullEncode", "required Level 2 filters")
+ }
+ if (is_HEX()) check_filter("ASCIIHexEncode", "ASCIIHexEncode filter")
+ if (is_LZW()) check_filter("LZWEncode", "LZWEncode filter")
+ if (is_RLE()) check_filter("RunLengthEncode", "RunLengthEncode filter")
+ if (is_ZIP()) check_filter("FlateEncode", "FlateEncode filter")
+}
+ function check_filter(name, expl) {
+ out_ps("/" name " /Filter resourcestatus {pop pop}")
+ out_ps("{(\\010!This version of Ghostscript doesn't support " expl "\\n\\007)")
+ out_ps(" print errq} ifelse")
+ }
+
+function errmessage(errname, errnum) {
+ print "CEP ERROR:", errname "\007"; exit(errnum)
+}
+
+ # searching for the most recent, i.e., active, options
+ # poszukiwanie ostatniej (obowi/azuj/acej) opcji
+function is_A85() {return (CVM~/8[^Hh]*$/) }
+function is_HEX() {return (CVM~/[Hh][^8]*$/) }
+function is_LZW() {return (CVM~/[Ll][^NnRrFf]*$/) }
+function is_RLE() {return (CVM~/[Rr][^NnLlFf]*$/) }
+function is_ZIP() {return (CVM~/[Ff][^NnLlRr]*$/) }
+
+function uncep_comment() {
+ s="%UNCEPInfo: " pre_lines+3 " " buff_num " " buff_len " " pos_lines+1
+ return s
+}
+
+function source() {
+ s="/_fltrd_file currentfile"
+ if (is_A85()) s=s " /ASCII85Decode filter"
+ if (is_HEX()) s=s " /ASCIIHexDecode filter"
+ if (is_LZW()) s=s " /LZWDecode filter"
+ if (is_RLE()) s=s " /RunLengthDecode filter"
+ if (is_ZIP()) s=s " /FlateDecode filter"
+ s=s " def /_read_string /readstring load def"
+ return s
+}
+
diff --git a/support/pstools/cep/cep.bat b/support/pstools/cep/cep.bat
new file mode 100644
index 0000000000..00b55cea08
--- /dev/null
+++ b/support/pstools/cep/cep.bat
@@ -0,0 +1,48 @@
+:: This file belongs to the CEP package | Ten plik nale/zy do pakietu CEP
+:: This package is public domain | Pakiet stanowi dobro powszechne
+:: For more info see `0CEP_LIC.ENG' | Wi/ecej informacji w ,,0CEP_LIC.POL''
+:: ===========================================================================
+:: E: Bitmap EPS file compression program
+:: This program compresses and codes, using standard methods of
+:: Postscript Level 2, bitmap EPS files (hexadecimal, not compressed).
+::
+:: P: Program do kompresji EPS-/ow bitmapowych.
+:: S/lu/zy on do pakowania oraz kodowania bitmapowych, kodowanych
+:: szesnastkowo, niekompresowanych plik/ow EPS za pomoc/a
+:: standardowych algorytm/ow Postscriptu Level 2.
+::
+@echo off
+if "%2"=="" goto USAGE
+if "%1"=="%2" goto USAGE
+if not exist %1 goto USAGE
+gawk32 -fcep.awk -vTMPSX=tmp.psx -vOUTF=%2 -vCVM=%3%4 %1
+if errorlevel==1 goto DONE
+SET DOS4G=quiet
+if exist tmp.psx call gs386.exe -q -dNODISPLAY tmp.psx
+if exist tmp.psx del tmp.psx
+echo .
+goto DONE
+::
+:USAGE
+echo E: USAGE:
+echo cep input_file output_file [options]
+echo the program recognizes the following options:
+echo 8 -- use ASCII85 coding (default)
+echo h or H -- use HEX (hexadecimal) coding
+echo r or R -- use RLE (RunLength) compression (default)
+echo l or L -- use LZW compression
+echo f or F -- use Flate compression (non-standard!)
+echo n or N -- don't compress
+echo (names of input_file and output_file must differ)
+echo.
+echo P: WYWO/LANIE:
+echo cep plik_wej/sciowy plik_wyj/sciowy [opcje]
+echo program rozpoznaje nast/epuj/ace opcje:
+echo 8 -- kodowanie ASCII85 (domy/slnie)
+echo h lub H -- kodowanie HEX -- szesnastkowe
+echo r lub R -- kompresja RLE -- RunLength (domy/slnie)
+echo l lub L -- kompresja LZW
+echo f lub F -- kompresja Flate (niestandardowa!)
+echo n lub N -- bez kompresji
+echo (nazwa pliku wyj/sciowego musi by/c r/o/zna od nazwy pliku wej/sciowego)
+:DONE
diff --git a/support/pstools/cep/cepcop_e.inf b/support/pstools/cep/cepcop_e.inf
new file mode 100644
index 0000000000..9bcb88db56
--- /dev/null
+++ b/support/pstools/cep/cepcop_e.inf
@@ -0,0 +1,371 @@
+This file belongs to the CEP package | Ten plik nale/zy do pakietu CEP
+This package is public domain | Pakiet stanowi dobro powszechne
+For more info see `0CEP_LIC.ENG' | Wi/ecej informacji w ,,0CEP_LIC.POL''
+===========================================================================
+`CEPCOP_E.INF' -- ENGLISH DOCUMENTATION
+
+The amount of disk space occupied by bitmap graphics is a well-recognized
+problem. For example, 300dpi picture A4 contains ca 8 700 000 pixels;
+assuming that each CMYK pixel occupies four bytes, one obtains ca 35MB
+of disk space needed to store the picture.
+
+Now, imagine a poor TeX-er, who is not allowed to use binary graphic data
+(because of the otherwise magnificent DVIPS), thus the poor TeX-er usually
+converts the binary data to hexadecimal EPSes, thus doubling the required
+space, and next, after compiling a document with TeX+DVIPS, the whole graphic
+data is put into the resulting PS file, so the required space is doubled
+again -- altogether 140MB per one A4 page. Night-mare begins...
+
+This problem is not a new one, it was was recognised by Adobe relatively long
+time ago. In the Level 2 specification they included objects called filters
+which enable data compression. In particular, instead of hexadecimal data one
+can use ASCII85 encoding (alike unix utility uuencode-uudecode), run length
+compression, LZW compression, DCT (used in JPEG compressed files), and many
+others. Why not to make use of these tools? The question is not as silly as
+it may look at the first glance, as there exist relatively few applications
+generating well-compressed PostScript graphics.
+
+We decided to patch somehow this gap. We developed a little package enabling
+the compression of ``normal'' (non-compressed) graphic data. The nature of
+the problem is more complex, however, than one might expect. In particular,
+a universal, always efficient compression technique does not exist. Hence the
+package has several ``buttons'' which enable controlling various aspects of
+compression.
+ * * *
+
+Our package consists of four AWK programs, CEP.AWK-UNCEP.AWK and
+COP.AWK-UNCOP.AWK. CEP.AWK and COP.AWK generate (on-the-fly) PostScript
+programs which, processed by Ghostscript, yield the appropriate data
+compression. UNCEP and UNCOP accomplish (using a similar technique) the
+reverse process, i.e., uncompression.
+
+CEP is devised for the compression of usual bitmap EPS files, containing
+a single, hexadecimally coded image; COP can be used to compress any
+PostScript data.
+
+The question arises: why to use two packing techniques? The answer is
+simple: the efficiency of compression is higher if a compressing program
+knows in advance which kind of data are to be expected. In general, bitmaps
+are more regular (redundant) than arbitrary PostScript data, hence even
+simple algorithms turn out to be more efficient.
+
+Tests show that in the best case (screen dumps) squeezing up to 10% of the
+original size is nothing unusual. Sometimes, however, no compression method
+gives a satisfactory result. In such a case, one can always use encoding data
+using ASCII85 filter, obtaining a reduction of a hexadecimal bitmap size by
+approximately 35%.
+
+Below we give a brief description of CEP and COP. So far, only the MS DOS
+version of the PS-compressors is available. In this version the GAWK-EMX.EXE
+implementation of AWK and GS386.EXE Ghostscript interpreter are used.
+
+We tested the package using several Ghostscript and GAWK implementations,
+now we use Ghostscript 5.10 and GAWK 3.0.3.
+
+==========================================================================
+ C E P AND U N C E P
+==========================================================================
+
+The CEP subpackage consist of the MS DOS batch files CEP.BAT and UNCEP.BAT
+and the AWK programs CEP.AWK and UNCEP.AWK. First, AWK inspects the source
+EPS file doing its best to recognize a position of a hexadecimal bitmap, next
+it creates an appropriate PostScript program, and then the control is passed
+on to Ghostscript which just performs the submitted program: encodes the
+bitmap and copies verbatim the remaining lines. The original preamble is
+slightly modified; nevertheless, all DSC comments are left intact.
+
+If the bitmap cannot be found or the AWK suspects that troubles may arise,
+the CEP engine gives up.
+
+The resulting file should be verified prior to removing the original one,
+as the CEP heuristic tricks may fail to fix the bitmap properly; moreover,
+due to GS bugs, premature removing of source may also be painful.
+
+CEP never generates binary output -- only hexadecimal or ASCII85 encoding
+are supported. This is due to the fact that CEP-compressed EPS files are
+primarily meant to be used in the contexts of TeX+DVIPS. Nevertheless,
+the resulting files can be used in other typesetting systems as so-called
+placeable EPSes. The applicability to non-TeX application, however,
+is somewhat limited, as binary TIFF previews may be misinterpreted by (G)AWK.
+
+UNCEP requires that a CEP-compressed file was not changed. In particular,
+it relies on the information in a quasi-DSC comment `%UNCEPInfo:'. This
+information can be destroyed by a seemingly innocent modification (e.g., by
+adding or removing a comment line). Note that the technique employed by CEP
+destroys, by its nature, the information about the line-breaking structure
+of the hexadecimal bitmap. Therefore, UNCEP cannot retrieve the original file.
+Line-breaking structure does not make any problem for a PostScript
+interpreter. There exist programs, however, reading their own bitmap EPS
+files, which for unknown reasons make use of such (sub)lexical information;
+Aldus PhotoStyler is a notable example.
+
+CEP USAGE: cep.bat input_file output_file [options]
+ the program recognizes the following options:
+ 8 -- use ASCII85 coding (default)
+ h or H -- use HEX (hexadecimal) coding
+ r or R -- use RLE (RunLength) compression (default)
+ l or L -- use LZW compression
+ f or F -- use Flate compression (non-standard!)
+ n or N -- don't compress
+NOTE: names of input_file and output_file must differ.
+
+UNCEP USAGE: uncep.bat input_file output_file
+NOTE: names of input_file and output_file must differ;
+ decompression and decoding method is taken from input file.
+
+==========================================================================
+ C O P AND U N C O P
+==========================================================================
+
+The subpackage consist of the MS DOS batch files COP.BAT and UNCOP.BAT, and
+the AWK programs COP.AWK and UNCOP.AWK. COP reads and encodes appropriately the
+supplied data. No analysis of the PostScript data is performed, as the entire
+file is encoded without changing even a bit. The only aspect that is taken
+into account is the DSC comment `%%BoundingBox:'; if it is found, COP inserts
+this comments in the preamble, otherwise the resulting file does not contain
+the bounding box information.
+
+COP-generated files are readable to any PostScript Level 2 interpreter.
+
+UNCOP scans the header and deduces from it the method of decompression, hence
+no options are needed. UNCOP, unlike UNCEP, retrieves precisely the original
+file. It is still recommended, however, that a user verifies whether the
+resulting file is properly interpreted by GS. Due to GS bugs, premature
+removing of the source file after compression or decompression may turn out
+to be painful.
+
+Since COP can be used to compress any data for arbitrary applications, also
+binary encoding is allowed. The resulting files can be used typesetting
+systems that accept so-called placeable EPSes. Unfortunately, binary TIFF
+previews makes files after compression illegible for PostScript.
+
+COP USAGE: cop.bat input_file output_file [options]
+ the program recognizes the following options:
+ 8 -- use ASCII85 coding (default)
+ b or B -- use binary coding
+ h or H -- use HEX (hexadecimal) coding
+ r or R -- use RLE (RunLength) compression (default)
+ l or L -- use LZW compression
+ f or F -- use Flate compression (non-standard!)
+ n or N -- don't compress
+NOTE: names of input_file and output_file must differ;
+ observe that binary encoding is, in fact, no encoding at all.
+
+UNCOP USAGE: uncop.bat input_file output_file
+NOTE: names of input_file and output_file must differ;
+ decompression and decoding method is taken from input file.
+
+=============================================================================
+ A HEAP OF REMARKS CONCERNING C E P AND C O P
+=============================================================================
+
+The applied solution addresses several problems:
+
+ * It is not at all obvious how to determine syntactically
+ where a hexadecimal bitmap begins in an EPS file; semantic analysis
+ (by redefining PostScript primitives image, imagemask and colorimage)
+ is possible, but it has also its limitations; anyway, we decided
+ to recognize a bitmap syntactically, which implied a problem of
+ recognizing such artefacts as `add' or `def' which look like
+ fragments of a bitmap but, in fact, they are not.
+
+ * Also, it is not obvious which compression method should be applied for
+ a given data; usually, ASCII85 encoding is advisable; for pure bitmaps
+ (CEP) RLE compression is satisfactory, although LZW and Flate filters
+ produce usually much better results (the latter seams to be the best);
+ nevertheless, both LZW and Flate encodings have limited usability:
+ (a) LZW encoding is not implemented in GS ver. 4.x due to USA
+ patent law; Aladdin implemented an LZW-compatible filter instead,
+ which produces non-compressed data (in fact, enlarged by some 10%)
+ readable for any LZWDecode filter. You can use old GS version,
+ or compile a GS version containing the real LZW filter on your
+ own risk, but...
+ (b) Flate encoding (the same that is used in GZIP) is not available
+ (yet?) on PostScript phototypesetters -- in the Ghostscript
+ documentation one can find a moderately encouraging passage:
+ ``Ghostscript also supports the as yet undocumented
+ FlateEncode and FlateDecode filters from PDF 1.2
+ and (presumably) PostScript Level 3''
+ As a rule of thumb we would suggest not to use any compression but
+ ASCII85 for detailed colour photo images. It is just weakness of all
+ non-lossy techniques -- algorithms employed by ARJ, ZIP, LHARC,
+ and others would yield also poor results. A reasonable alternative
+ for the data of this kind would be DCT (JPEG) compression.
+
+ * As was mentioned above, ASCII85 encoding can usually be recommended;
+ it added, however, some troubles. First, due to GS bugs, we decided
+ to add the (dummy) NullEncode filter which seems to cure the problem.
+ But there is one more problem: ASCII85 encoded bitmaps may contain
+ lines looking like DSC comments, i.e, they may begin with double percent
+ sign, %%, or with a pair percent-exclamation sign, %! -- why Adobe
+ didn't exclude a percent from ASCII85?. Some programs may try to
+ interprete maybe-DSC lines. For example, DVIPS just removes
+ such lines, unless option -K0 is not used; on the other hand,
+ leaving DSC comments intact may stupefy document managers.
+
+ * It would be convenient to have some more filters implemented, in
+ particular DCT and CCITTFax; both of them, however, make use of some
+ additional input data which makes using them more complex; moreover,
+ it is not clear whether one can find the optimal compression parameters
+ for DCT without a WYSIWYG program; we consider a possibility of
+ one-to-one conversion between JPEG files and EPS files making use of
+ DCT filters; also, a similar conversion between GIF files and EPS files
+ making use of LZW filters can perhaps be implemented.
+
+ * The package takes care of the working disk space -- no large temporary
+ files are created; roughly, the needed disk space is equal to the size
+ of the source + the size of the target.
+
+ * In order to check whether a given phototypesetter is a genuine
+ PostScript Level 2 interpreter, a trial-and-error method is necessary,
+ since many commercial PostScript devices only claim to be Level 2
+ compatible. The following file may be helpful for verifying
+ the claims of the producer of a PostScript device:
+
+ %!PS-Adobe-2.0 EPSF-1.2
+ %%Pages: 1
+ %%BoundingBox: 0 0 540 150
+ %%EndComments
+ /Helvetica 8 selectfont
+ 90 rotate
+ 1 2 moveto
+ (*)
+ {0 -10 rmoveto gsave show grestore}
+ 255 string
+ /Filter
+ resourceforall
+ showpage
+ %%EOF
+
+ Running this program yields the list of filters for a given device.
+ The error reported during the processing of this file proves that
+ the device is not Level 2 compatible. In such a case, using the
+ CEP package should be abandoned.
+
+ * bugs and traps:
+
+ (a) Apparently prepending `flushfile' to `closefile' neutralizes an
+ error in GS 3.x (tail of output swallowed).
+
+ (b) Adding (a dummy) NullEncode filter neutralizes (probably) another
+ GS bug: ASCII85Encode filter with target procedure may produce
+ superfluous EOD marks, i.e., ~> (if things go really bad you can
+ obtain thousands of them). Using the target procedure instead of
+ a file object excludes GS ver. < 3.x, because early Ghostscripts
+ didn't support all features of PostScript Level 2. Nevertheless,
+ GS ver. >= 2.6 can be used for compression with hexadecimal encoding
+ (it has the ``legal'' LZW compression)
+
+ (c) the target procedure mentioned (b), in turn, is due to special
+ treatment of the ASCII85 encoded lines looking like DSC comments;
+ this special treatment is breaking lines after the first percent
+ character. It is dedicated to the DVIPS driver which has a dangerous
+ option `remove comments' (-K1)
+
+ (d) an artificial form of quitting `{2 2 .quit}' instead of `{2 .quit}'
+ is due to an infinite loop of GS 3.5x caused by the latter form.
+ The GS internal operation `.quit' was chosen to provide error
+ handling at the level of operating system.
+
+ (e) still, there exist bugs in older Ghostscripts that we were not able
+ to neutralize; e.g., some EPS files are properly compressed
+ by GS 2.6, but GS 2.6 breaks while displaying them; GS 3.51
+ behaves similarly with other bitmaps. So far, GS 4.x seems to be
+ the most resistant to the ``filter trial,'' but it also reveals
+ some deficiences.
+
+ (f) summing up, we would strongly recommend using GS 4.x or 5.x
+ (possibly with LZWEncode compiled in) and GAWK 3.x: GS 4.x is
+ nearly complete implementation of the Level 2 PostScript;
+ GAWK 3.x provides regular expressions for record separators,
+ which makes possible to force to handle end-of-lines in exactly
+ the same manner as PostScript does and, moreover, is more reliable
+ than earlier versions.
+
+==========================================================================
+ H I S T O R Y
+==========================================================================
+
+CEP+UNCEP:
+ 0.10 -- 16.03.97 -- first version
+ 0.20 -- 05.04.97 -- some obvious bugs removed
+ 0.30 -- 11.04.97 -- new method of prolog modification (processing complex
+ prologs is enabled), and merging output file in
+ Postscript (faster and less disk space needed)
+
+ 0.35 -- 13.04.97 -- comments added (bilingual version)
+ 0.40 -- 14.04.97 -- significant improvement of performance
+ 0.50 -- 15.04.97 -- strings allocated statically, temporary files not
+ created, (speed improved and demand for disk space
+ slashed)
+ 0.60 -- 19.04.97 -- postScript error handling added, some GS bugs
+ neutralized
+ 0.65 -- 20.04.97 -- exit code added, frame documentation provided
+ 0.70 -- 21.04.97 -- UNCEP added
+ 0.75 -- 24.04.97 -- problems of end-of-data and end-of-lines fixed;
+ documentation collected
+ 1.00 -- 02.05.97 -- public domain release (BachoTeX '97)
+ 1.03 -- 07.01.98 -- documentation touched, package (CEP.AWK) more robust
+
+COP+UNCOP:
+ 0.10 -- 06.04.97 -- first version
+ 0.20 -- 12.04.97 -- program structure unified with CEP, "cvx exec" used
+ in place of "run"
+ 0.25 -- 13.04.97 -- comments added (bilingual version)
+ 0.30 -- 15.04.97 -- strings allocated statically (speed improved)
+ 0.40 -- 19.04.97 -- postScript error handling added, some GS bugs
+ neutralized
+ 0.45 -- 20.04.97 -- exit code added, frame documentation provided
+ 0.50 -- 24.04.97 -- problems of end-of-lines fixed; documentation collected
+ 1.00 -- 02.05.97 -- public domain release (BachoTeX '97)
+ 1.03 -- 07.01.98 -- documentation touched, package (CEP.AWK) more robust
+
+==========================================================================
+ V O C A B U L A R Y
+==========================================================================
+
+Ghostscript, GS -- a magnificent interpreter of PostScript language
+ by Aladdin Enterprise, available as a free public license product;
+ its current version (4.03) turns out to be much more reliable
+ than not a few commercial interpreters.
+AWK -- a utility and a programming language for convenient and efficient
+ batch data-reformatting; written in 1977 by Alfred V. Aho,
+ Peter J. Weinberger, and Brian W. Kernighan.
+GAWK -- Gnu AWK, GNU Free Software Foundation implementation of AWK,
+ written in 1986 by Paul Rubin and Jay Fenlason, with advice
+ from Richard Stallman.
+GNU -- The Free Software Foundation (FSF) is a non-profit organization
+ dedicated to the production and distribution of freely
+ distributable software, founded by Richard M. Stallman.
+TeX -- public domain typesyetting system by Donald E. Knuth of
+ Stanford University
+DVIPS -- TeX-to-PostScript driver by Tomas Rokicki of Stanford University
+DSC -- Document Structuring Convention -- Adobe's standard
+ for structuring PostScript documents.
+ASCII85 -- PostScript algorithm of coding binary data as 7-bit ASCII
+ text consisting of only printable characters; encodes every
+ four bytes as five characters from `%' to `u'; additionaly
+ `z' is used to code four zeros (see PostScript Language
+ Reference Manual, second edition, pp. 128--130)
+RLE -- run length encoding -- a standard method of data compression
+ (see PostScript Language Reference Manual, second edition,
+ pp. 133--134)
+LZW -- an algorithm of data compression by J. Ziv, A. Lempel (1978),
+ improved by T. Welch (1984); Unisys, at the time Welch's employer,
+ was granted an US patent in 1985 on Welch's algorithm; a grandfather
+ clause was established by Unisys to make pre-1995 implementations
+ of LZW code free of royalty requirements, thereby eliminating such
+ claims on UNIX compress (information after Nelson H. F. Beebe,
+ e-mail beebe@math.utah.edu)
+DCT -- discrete cosine transform compression, an elaborated, very
+ efficient but lossy compression scheme
+JPEG -- Joint Photographic Experts Group, an organization responsible
+ for developing an international standard for compression of
+ image data; PostScript (Level 2) DCTEncoding filter conforms
+ to the JPEG-proposed standard.
+GZIP -- compressing tool by GNU Free Software Foundation, based on
+ superior and unpatented compression algorithm, developed in order
+ to get rid of the patented LZW algorithm.
+=======================================================================
+END OF `CEPCOP_E.INF'
+
diff --git a/support/pstools/cep/cepcop_p.inf b/support/pstools/cep/cepcop_p.inf
new file mode 100644
index 0000000000..9e5ab9715a
--- /dev/null
+++ b/support/pstools/cep/cepcop_p.inf
@@ -0,0 +1,478 @@
+This file belongs to the CEP package | Ten plik nale/zy do pakietu CEP
+This package is public domain | Pakiet stanowi dobro powszechne
+For more info see `0CEP_LIC.ENG' | Wi/ecej informacji w ,,0CEP_LIC.POL''
+===========================================================================
+,,CEPCOP_P.INF'' -- DOKUMENTACJA POLSKA
+
+Osoby zajmuj/ace si/e obr/obk/a danych graficznych od zawsze maj/a k/lopoty
+z ogromnymi i wci/a/z rosn/acymi plikami. Na przyk/lad grafika formatu A4
+przeskanowana w rozdzielczo/sci 300 DPI sk/lada si/e z ok. 8 700 000 pikseli.
+Je/sli jest to kolorowa mapa bitowa, w kt/orej ka/zdy piksel opisany jest
+czterema bajtami (CMYK), to zajmuje ona na dysku w przybli/zeniu 35 MB.
+
+Niestety, to dopiero pocz/atek. U/zytkownik TeX-a nie mo/ze u/zywa/c danych
+w postaci binarnej (nie pozwala na to niestety DVIPS). Nasz biedny TeX-nik
+konwertuje wi/ec grafik/e do postaci szesnastkowego EPS, co dwukrotnie
+zwi/eksza zajmowane przez ni/a miejsce. Pami/etajmy r/ownie/z, /ze trzeba
+zarezerwowa/c sobie co najmniej jeszcze raz tyle miejsca na dysku, aby mia/l
+gdzie powsta/c po przetworzeniu dokumentu TeX-em i DVIPS-em wynikowy plik .PS
+zawieraj/acy ca/l/a informacj/e graficzn/a. Okazuje si/e wi/ec, /ze na
+ka/zd/a stron/e A4 potrzebujemy 140 MB na dysku. A dyski niestety
+kosztuj/a...
+
+Problem ten jest znany ju/z od dawna. Firma Adobe, tworz/ac wiele lat temu
+PostScript, najpopularniejszy j/ezyk opisu strony, zawar/la w specyfikacji
+poziomu drugiego (Level 2) obiekty zwane filtrami, umo/zliwiaj/ace kompresj/e
+danych. Mo/zemy wi/ec zamiast kodowania szesnastkowego zastosowa/c kodowanie
+ASCII85 (podobne do tego z UNIX-owego uuencode). Mamy te/z dost/ep do
+kompresji algorytmem ,,run length'', algorytmem LZW, stosowanym w plikach
+JPEG algorytmem DCT, a tak/ze kilku innych. Nasuwa si/e pytanie, dlaczego
+w codziennej praktyce nie stosuje si/e tych metod kompresji? Ot/o/z niewiele
+program/ow -- nie wiedzie/c czemu -- potrafi zapisa/c grafik/e w postaci
+skompresowanych plik/ow EPS, a do tego s/a to programy ma/lo popularne.
+
+Poni/zszy pakiet w pewnym zakresie rozwi/azuje ten problem. Umo/zliwia on
+kompresowanie najcz/e/sciej spotykanych, nieskompresowanych PostScript-owych
+plik/ow graficznych. Niestety, w trakcie pracy nad programem okaza/lo si/e,
+/ze problem jest bardziej skomplikowany, ni/z si/e pocz/atkowo wydawa/lo.
+Na przyk/lad nie da si/e wybra/c jednego, najlepszego algorytmu kompresji
+i zawsze go stosowa/c. Wyb/or ten musi zale/ze/c od rodzaju kompresowanych
+danych, ich postaci, a tak/ze spodziewanego zastosowania. Z tego w/la/snie
+powodu pakiet sk/lada si/e z a/z dw/och zestaw/ow program/ow, z kt/orych
+ka/zdy posiada kilka opcji, umo/zliwiaj/acych pewne sterowanie procesem
+kompresji.
+
+ * * *
+
+Nasz pakiet sk/lada si/e z dw/och par program/ow AWK-owych: CEP.AWK-UNCEP.AWK
+oraz COP.AWK-UNCOP.AWK. CEP.AWK i COP.AWK tworz/a na podstawie analizy danych
+wej/sciowych program PostScript-owy, kt/ory przetwarzany przez Ghostscript-a,
+dokonuje w/la/sciwej kompresji danych i tworzy plik wynikowy. UNCEP.AWK
+i UNCOP.AWK wykonuj/a (u/zywaj/ac zbli/zonej metody) proces odwrotny,
+to znaczy dekompresj/e danych do postaci wej/sciowej.
+
+CEP zosta/l stworzony do kompresji cz/esto spotykanych plik/ow EPS
+zawieraj/acych pojedyncz/a map/e bitow/a zakodowan/a szesnastkowo;
+COP potrafi skompresowa/c dowolne dane PostScript-owe.
+
+Powstaje pytanie, po co u/zywa/c CEP-a, je/zeli COP potrafi skompresowa/c
+dowolny plik PostScript-owy. Odpowied/x jest bardzo prosta -- CEP wie, jakich
+danych si/e spodziewa/c, i w zwi/azku z tym potrafi je spakowa/c du/zo
+efektywniej. Poprawa efektywno/sci wynika z dw/och czynnik/ow. Po pierwsze
+CEP spodziewa si/e danych szesnastkowych, czyli przyjmuje, /ze dwa znaki kodu
+opisuj/a jeden bajt mapy bitowej (co ju/z powoduje zwi/ekszenie upakowania
+informacji). Po drugie mapy bitowe maj/a najcz/e/sciej zdecydowanie bardziej
+regularn/a (redundantn/a) struktur/e ni/z przeci/etny kod PostScript-owy.
+Wynika z tego, /ze w przypadku map bitowych nawet prostsze algorytmy
+kompresji mog/a da/c bardzo dobre rezultaty.
+
+Z naszych eksperyment/ow wynika, /ze przy dobrych danych wej/sciowych (zrzuty
+grafiki z ekranu) /latwo jest osi/agn/a/c nawet dwudziestokrotn/a kompresj/e.
+Niestety, w niekt/orych przypadkach /zadna metoda kompresji nie daje
+efekt/ow. W takiej sytuacji zawsze mo/zemy zastosowa/c filtr ASCII85, kt/ory
+zmniejszy obj/eto/s/c mapy bitowej zakodowanej szesnastkowo o oko/lo 35%.
+
+Poni/zej kr/otko opisujemy dzia/lanie CEP-a i COP-a. Jak na razie, pakiet ten
+dzia/la tylko w systemie MS DOS, cho/c mamy nadziej/e, /ze uda si/e go /latwo
+przenie/s/c na inne platformy, tam gdzie s/a dost/epne GAWK i Ghostscript.
+W tej wersji zastosowali/smy implementacj/e AWK-a stworzon/a w ramach
+inicjatywy GNU: GAWK32.EXE oraz wersj/e Ghostscript-a dla systemu DOS:
+GS386.EXE.
+
+Do test/ow pakietu u/zywali/smy kilku wersji Ghostscripta i GAWK-a.
+Aktualnie u/zywamy ju/z Ghostscripta w wersji 5.10 oraz GAWK 3.0.3.
+(w wersji 32-bitowej -- GAWK32.EXE) i nie zauwa/zyli/smy /zadnych
+problem/ow.
+
+==========================================================================
+ C E P i U N C E P
+==========================================================================
+
+W sk/lad podpakietu CEP wchodz/a DOS-owe pliki wsadowe CEP.BAT i UNCEP.BAT
+oraz programy AWK-owe CEP.AWK i UNCEP.AWK. Po wywo/laniu pliku wsadowego
+najpierw uruchamiany jest AWK, kt/ory przegl/ada dane wej/sciowe, stara si/e
+znale/x/c w nich map/e bitow/a zakodowan/a szesnastkowo i tworzy odpowiedni
+program PostScript-owy. Nast/epnie zostaje uruchomiony Ghostscript, kt/ory
+wykonuj/ac przygotowany w poprzednim kroku program, dokonuje w/la/sciwego
+przetwarzania danych. Przepisuje on te/z oryginaln/a preambu/l/e
+PostScript-ow/a dokonuj/ac w niej tylko kilku zmian; /zadne komentarze DSC
+nie ulegaj/a zmianie.
+
+Je/zeli program nie znajdzie w pliku mapy bitowej albo w trakcie analizy
+struktury pliku powstaj/a jakie/s problemy, CEP poddaje si/e i nie tworzy
+wynikowego EPS-a.
+
+Przed skasowaniem oryginalnej wersji zalecamy sprawdzenie, czy powsta/ly plik
+jest prawid/lowy. W niekt/orych (rzadkich) przypadkach CEP mo/ze b/l/ednie
+rozpozna/c map/e bitow/a. Czasami tak/ze b/l/edy Ghostscript-u mog/a
+powodowa/c powstanie uszkodzonego pliku, wi/ec lepiej zawsze obejrze/c
+go przed usuni/eciem /xr/od/la.
+
+CEP nie tworzy binarnych plik/ow wyj/sciowych, zawsze stosuje kodowanie
+ASCII85 lub szesnastkowe. Wynika to z naszego za/lo/zenia, /ze kompresowane
+CEP-em pliki b/ed/a u/zywane g/l/ownie w /srodowisku TeX-owym z DVIPS-em jako
+sterownikiem PostScript-owym. Niezale/znie od tego za/lo/zenia pliki CEP-owe
+mo/zna u/zywa/c w dowolnych systemach DTP, kt/ore wczytuj/a tak zwane
+,,placeable EPS''. Niestety takie systemy najcz/e/sciej wymagaj/a EPS-/ow
+zawieraj/acych podgl/ad w postaci binarnego TIFF-a, kt/ory mo/ze zosta/c
+/xle przetworzony przez (G)AWK-a.
+
+UNCEP dekompresuje wszystkie pliki stworzone CEP-em pod warunkiem, /ze nie
+zosta/ly one w /zaden spos/ob zmienione. W skompresowanym pliku wyst/epuje
+specjalny komentarz ,,%UNCEPInfo:'', kt/ory zawiera informacje potrzebne do
+dekompresji. Jest on jednak bardzo czu/ly na budow/e pliku. Nawet tak
+nieznaczna zmiana jak dodanie (lub usuni/ecie) linii komentarza powoduje, /ze
+pliku nie daje si/e rozkompresowa/c. Trzeba te/z zwr/oci/c uwag/e na to, /ze
+podstaw/a kompresji jest tu przetwarzanie strumienia danych, czyli ci/agu
+liczb, a nie ci/agu znak/ow, co implikuje, /ze informacja o sposobie /lamania
+wierszy podczas czytania danych szesnastkowych jest tracona. W zwi/azku z tym
+UNCEP nie mo/ze wygenerowa/c pliku identycznego z wej/sciowym. Nie ma to
+/zadnego znaczenia dla PostScript-u, gdy/z jest on ca/lkowicie odporny na
+r/o/zne metody /lamania linii. Niestety niekt/ore programy ,,czytaj/ace''
+pliki EPS z niezrozumia/lych przyczyn wymagaj/a /lamania linii wed/lug
+w/lasnych zasad. Tego typu programy (np. Aldus PhotoStyler) nie odczytaj/a
+zdekompresowanego pliku.
+
+U/ZYCIE CEP-a: cep.bat plik_wej/sciowy plik_wyj/sciowy [opcje]
+ program rozpoznaje nast/epuj/ace opcje:
+ 8 -- kodowanie ASCII85 (domy/slnie)
+ h lub H -- kodowanie HEX (szesnastkowe)
+ r lub R -- kompresja RLE (RunLength) (domy/slnie)
+ l lub L -- kompresja LZW
+ f lub F -- kompresja Flate (niestandardowa!)
+ n lub N -- bez kompresji
+UWAGA: nazwa pliku wyj/sciowego musi by/c r/o/zna od nazwy pliku wej/sciowego
+
+U/ZYCIE UNCEP-a: uncep.bat plik_wej/sciowy plik_wyj/sciowy
+UWAGA: nazwa pliku wyj/sciowego musi by/c r/o/zna od nazwy pliku wej/sciowego,
+ metoda dekompresji jest ustalana na podstawie pliku wej/sciowego.
+
+==========================================================================
+ C O P i U N C O P
+==========================================================================
+
+W sk/lad podpakietu COP wchodz/a DOS-owe pliki wsadowe COP.BAT i UNCOP.BAT
+oraz programy AWK-owe COP.AWK i UNCOP.AWK. COP czyta i odpowiednio koduje
+zupe/lnie niemodyfikowany plik wej/sciowy. Nie przeprowadza on w/la/sciwie
+/zadnej analizy danych PostScript-owych. Jedynym wyj/atkiem jest pr/oba
+odnalezienia komentarza strukturalnego ,,%%BoundingBox:''. Je/sli pr/oba
+si/e powiedzie, jest on do/l/aczany do generowanej preambu/ly, w przeciwnym
+przypadku preambu/la nie zawiera komentarza ,,%%BoundingBox:''.
+
+Pliki wygenerowane przez COP-a s/a czytane przez ka/zdy interpreter
+PostScript-u Level 2.
+
+Przy wywo/laniu UNCOP-a nie trzeba ustawia/c /zadnych opcji, ustala on bowiem
+metod/e dekompresji na podstawie nag/l/owka pliku wej/sciowego. UNCOP,
+w przeciwie/nstwie do UNCEP-a, odtwarza dok/ladnie ka/zdy bit oryginalnego
+pliku. Niestety, z powodu b/l/ed/ow Ghostscript-a usuni/ecie pliku
+/xr/od/lowego przed sprawdzeniem, czy plik wynikowy jest prawid/lowy, mo/ze
+si/e sko/nczy/c niemi/l/a niespodziank/a. Dlatego przed skasowaniem /xr/ode/l
+zalecamy obejrzenie rozkompresowanego pliku pod Ghostscript-em.
+
+COP mo/ze by/c u/zywany do kompresowania wszelkich danych dla r/o/znych
+aplikacji, tak wi/ec zdecydowali/smy si/e w tym przypadku dopu/sci/c
+mo/zliwo/s/c kodowania binarnego. Kompresowane EPS-y niestety nie mog/a
+zawiera/c podgl/adu TIFF-owego, wykorzystywanego przez wiele program/ow
+przetwarzaj/acych grafik/e PostScript-ow/a. Plik wynikowy mo/ze by/c u/zywany
+jako tak zwany placeable EPS bez podgl/adu (preview), mo/zna te/z wczytywa/c
+skompresowane pliki jako tak zwany ,,PostScript interpreted''. Niekiedy si/e
+to udaje, ale nie nale/zy si/e dziwi/c, je/sli si/e to nie powiedzie --
+interpretacja PostScript-u to naprawd/e trudne zadanie.
+
+U/ZYCIE COP-a: cop.bat plik_wej/sciowy plik_wyj/sciowy [opcje]
+ program rozpoznaje nast/epuj/ace opcje:
+ 8 -- kodowanie ASCII85 (domy/slnie)
+ b lub B -- kodowanie binarne
+ h lub H -- kodowanie HEX (szesnastkowe)
+ r lub R -- kompresja RLE (RunLength) (domy/slnie)
+ l lub L -- kompresja LZW
+ f lub F -- kompresja Flate (niestandardowa!)
+ n lub N -- bez kompresji
+UWAGA: nazwa pliku wyj/sciowego musi by/c r/o/zna od nazwy pliku wej/sciowego;
+ kodowanie binarne polega na wy/l/aczeniu jakiegokolwiek kodowania.
+
+U/ZYCIE UNCOP-a: uncop.bat plik_wej/sciowy plik_wyj/sciowy
+UWAGA: nazwa pliku wyj/sciowego musi by/c r/o/zna od nazwy pliku wej/sciowego
+ metoda dekompresji jest ustalana na podstawie pliku wej/sciowego
+
+=============================================================================
+ S T E R T A U W A G O C E P-ie I C O P-ie
+=============================================================================
+
+Poni/zej podajemy rozwi/azania niekt/orych problem/ow napotkanych podczas
+tworzenia pakietu:
+
+ * Nie ma prostej metody znajdowania zakodowanej szesnastkowo mapy bitowej
+ w pliku EPS. Analiza semantyczna (do zrealizowania przez przedefiniowanie
+ instrukcji ,,image'', ,,imagemask'' i ,,colorimage'') jest bardzo trudna
+ do pe/lnej realizacji (parametry w postaci s/lownik/ow). Zdecydowali/smy
+ si/e wi/ec na wyszukiwanie mapy bitowej oparte na analizie sk/ladni --
+ to z kolei wywo/la/lo k/lopoty z analiz/a napis/ow ,,add'' oraz ,,def'',
+ kt/ore mog/a by/c zar/owno cz/e/sci/a mapy bitowej, jak i instrukcj/a
+ PostScript-ow/a.
+
+ * Nie da si/e tak/ze poda/c dok/ladnych wytycznych, kt/ora metoda kompresji
+ b/edzie najlepsza dla konkretnych danych. Zwykle najlepsz/a metod/a
+ kodowania jest ASCII85. Dla map bitowych (kompresowanych CEP-em)
+ najcz/e/sciej wystarczy algorytm RLE, cho/c dla kolorowych rysunk/ow
+ lepszy jest LZW. Najlepsze wyniki prawie zawsze daje metoda Flate.
+ Jednak Flate, jak r/ownie/z LZW maj/a ograniczone zastosowania:
+ (a) kompresja LZW zosta/la w wersjach 4.x Ghostscript-u wy/l/aczona
+ z powodu nieszcz/esnego patentu (p. ,,S/lowniczek'' zamieszczony
+ na ko/ncu). Aladdin zastosowa/l zast/epczo filtr koduj/acy
+ zgodny z LZW, kt/ory niestety nie kompresuje danych (a nawet
+ je zwi/eksza o 10%). Mo/zna u/zywa/c starszych wersji
+ Ghostscript-a (maj/a one kilka b/l/ed/ow) lub skompilowa/c
+ GS z filtrem LZW na w/lasn/a odpowiedzialno/s/c, ale...
+ (b) kompresja Flate na razie niestety nie jest dost/epna
+ w fotona/swietlarkach. Po prostu nie wchodzi w sk/lad specyfikacji
+ PostScript-u Level 2. Jest nadzieja, /ze kiedy/s ten stan si/e
+ zmieni i algorytm Flate (taki sam jak u/zywany w GZIP-ie)
+ wejdzie do specyfikacji j/ezyka. W dokumentacji Ghostscript-a
+ znajdujemy bowiem zdanie (w wolnym t/lumaczeniu):
+ ,,Ghostscript obs/luguje r/ownie/z nieudokumentowane
+ filtry FlateEncode and FlateDecode, zawarte
+ w specyfikacji formatu PDF 1.2 oraz (przypuszczalnie)
+ PostScript-u poziomu trzeciego''
+ Z naszych do/swiadcze/n wynika, /ze w przypadku skan/ow zdj/e/c
+ najlepsze wyniki daje wy/l/aczenie kompresji i stosowanie tylko kodowania
+ ASCII85. W przypadku takich danych /zadna bezstratna metoda kompresji
+ nie jest w stanie nic zmieni/c (zdj/ecia zawieraj/a du/zo informacji
+ szumowej). Nawet takie programy jak ARJ, ZIP czy LHARC nie dadz/a
+ istotnie lepszych wynik/ow. Jedyn/a mo/zliwo/sci/a jest kompresja
+ fotografii algorytmami stratnymi, takimi jak stosowany w plikach JPEG
+ algorytm DCT.
+
+ * Zgodnie z tym co powiedzieli/smy wy/zej, najcz/e/sciej polecane jest
+ stosowanie kodowania ASCII85, niestety wywo/luje ono pewne problemy.
+ Po pierwsze, aby omin/a/c b/l/ad Ghostscript-a (nadmiarowe znaczniki
+ ko/nca danych), musieli/smy u/zy/c dodatkowego, pustego filtru
+ NullEncode. Pojawia si/e niestety r/ownie/z drugi powa/zniejszy problem:
+ dane zakodowane filtrem ASCII85 mog/a zawiera/c linie, kt/ore do/s/c
+ skutecznie podszywaj/a si/e pod komentarze strukturalne. Mianowicie
+ rozpoczynaj/a si/e od dw/och znak/ow procenta ,,%%'' lub od procenta
+ i wykrzyknika ,,%!''. W tym kontek/scie wydaje si/e dziwne, /ze firma
+ Adobe nie zdecydowa/la si/e na usuni/ecie procenta z zestawu znak/ow
+ ASCII85. Niestety nie uczyni/la tego, wi/ec niekt/ore programy
+ u/zywaj/ace plik/ow EPS, mog/a pr/obowa/c przetwarza/c linie zawieraj/ace
+ takie ,,niby-komentarze''. DVIPS jest tego przyk/ladem -- standardowo
+ usuwa linie komentarzy z wczytywanych plik/ow. Mo/zna zablokowa/c t/e
+ funkcj/e (-K0), ale wtedy pozostaj/a r/ownie/z prawdziwe komentarze
+ DSC, kt/ore mog/a powodowa/c b/l/edy w analizie dokumentu przez programy
+ korzystaj/ace z konwencji DSC.
+
+ * Przydatne mog/loby by/c w/l/aczenie do pakietu jeszcze kilku standardowych
+ filtr/ow PostScript-u, na przyk/lad DCT oraz CCITTFax. Jednak filtry te
+ wymagaj/a podania wielu parametr/ow wej/sciowych, wi/ec korzystanie z nich
+ by/loby du/zo bardziej skomplikowane. Co wi/ecej, w/la/sciwie nie wiadomo,
+ jak mo/zna ustala/c parametry kompresji DCT, nie maj/ac mo/zliwo/sci
+ interakcyjnego korygowania efekt/ow. Na razie wi/ec nie oprogramowali/smy
+ tych filtr/ow. W zamian przygotowujemy programik umo/zliwiaj/acy
+ konwersj/e plik/ow JPEG (czyli bardzo mocno skompresowanych bitmap)
+ do postaci PostScript-owych EPS-/ow (u/zywaj/acych filtra DCT).
+
+ * W pakiecie CEP starali/smy si/e oszcz/ednie gospodarowa/c przestrzeni/a
+ dyskow/a. W czasie pracy nie s/a tworzone /zadne du/ze pliki tymczasowe;
+ w/la/sciwie do kompresji pliku potrzebne jest tyle wolnego miejsca na
+ dysku, ile zajmuje plik wynikowy.
+
+ * W czasie p/o/lrocznej eksploatacji pakietu okaza/lo si/e, /ze
+ w wypadku niekt/orych komercyjnych urz/adze/n PostScript-owych
+ zgodno/s/c z standardem PostScript Level 2 ko/nczy si/e na
+ efektownych ulotkach i nalepce na obudowie. Cz/e/s/c na/swietlarek
+ (zw/laszcza starszych) nie jest w stanie, mimo obietnic producent/ow,
+ przetwarza/c poprawnie plik/ow *.ps zawieraj/acych operacje zwi/azane
+ z obiektami typu filter.
+
+ Jedyn/a metod/a sprawdzenia czy dana na/swietlarka prawid/lowo
+ realizuje wymienione filtry jest niestety metoda pr/ob i b/l/ed/ow.
+ W wypadku korzystania z na/swietlarki, kt/ora odmawia wsp/o/lpracy
+ z pakietem CEP (czyli nie jest zgodna z PostScript-em Level 2),
+ mo/zemy: (a) zmieni/c na/swietlarni/e, (b) wymusi/c na na/swietlarni
+ zakup nowego urz/adzenia, lub ewentualnie uaktualnienia
+ oprogramowania na/swietlarki (w przypadku RIP-a programowego)
+ lub (c) zrezygnowa/c z u/zywania CEP-a.
+
+ Pomocny mo/ze okaza/c si/e tu kr/otki plik PostScript-owy:
+
+ %!PS-Adobe-2.0 EPSF-1.2
+ %%Pages: 1
+ %%BoundingBox: 0 0 540 150
+ %%EndComments
+ /Helvetica 8 selectfont
+ 90 rotate
+ 1 2 moveto
+ (*)
+ {0 -10 rmoveto gsave show grestore}
+ 255 string
+ /Filter
+ resourceforall
+ showpage
+ %%EOF
+
+ Program ten spowoduje wypisanie listy filtr/ow obs/lugiwanych przez
+ dany interpreter. Je/sli w czasie przetwarzania pojawia si/e b/l/ad
+ (obs/luga w studiu graficznym twierdzi, /ze ,,plik si/e nie
+ RIP-uje''), to najprawdopodobniej mamy do czynienia ze zbyt ubog/a
+ wersj/a PostScript-u i musimy zrezygnowa/c z u/zywania CEP-a.
+
+ Powy/zszy plik mo/zna albo bezpo/srednio wys/la/c na urz/adzenie
+ PostScript-owe (na/swietlark/e, drukark/e), albo umie/sci/c
+ w dokumencie TeX-owym jak zwyk/ly plik EPS.
+
+ * B/l/edy i pu/lapki:
+
+ (a) Poprzedzenie komendy ,,closefile'' teoretycznie nadmiarow/a komend/a
+ ,,flushfile'' pozwala omin/a/c pluskw/e w GS 3.x (zjadanie ko/nc/owki
+ pliku wyj/sciowego).
+
+ (b) Dodatkowy, pusty filtr NullEncode pozwala nam omin/a/c (prawdopodobnie)
+ pewn/a pluskw/e Ghostscript-a. Mianowicie filtr ASCII85 z wyj/sciem
+ danych skierowanym do procedury cz/esto zapisuje w strumieniu
+ wynikowym dodatkowe znaczniki ko/nca danych, czyli ~> (przy pewnych
+ parametrach mo/ze zapisa/c ich tysi/ace). Skierowanie danych
+ wyj/sciowych do procedury, zamiast bezpo/srednio do pliku niestety
+ uniemo/zliwia stosowanie wcze/sniejszych ni/z 3.x wersji
+ Ghostscript-a przy kodowaniu ASCII85. Na szcz/e/scie GS w wersji
+ od 2.6x mo/ze by/c stosowany przynajmniej do kodowania szesnastkowego
+ (HEX) -- ta wersja Ghostscript-a zawiera r/ownie/z ,,legaln/a''
+ kompresj/e LZW.
+
+ (c) Procedura docelowa, o kt/orej pisali/smy w punkcie (b), zosta/la
+ dodana, aby specjalnie zmodyfikowa/c wiersze, kt/ore mog/lyby by/c
+ b/l/ednie zinterpretowane jako komentarze DSC. Specjalne traktowanie
+ polega na prze/lamaniu wiersza po znaku procenta. Zabezpiecza to
+ przed konsekwencjami cz/esto stosowanej, a w tym wypadku bardzo
+ gro/xnej opcji DVIPS-a ,,usuwaj komentarze'' (-K1).
+
+ (d) Dziwaczna sk/ladnia komendy ,,{2 2 .quit}'' zamiast formy
+ ,,{2 .quit}'' zosta/la zastosowana z powodu b/l/edu w GS 3.5x,
+ kt/ory wpada/l w niesko/nczon/a p/etl/e. Wewn/etrzn/a instrukcj/e
+ Ghostscript-a ,,.quit'' wybrali/smy po to, by umo/zliwi/c obs/lug/e
+ b/l/ed/ow na poziomie systemu operacyjnego.
+
+ (e) W starszych wersja Ghostscript-a wyst/epuje jeszcze jeden dziwny
+ b/l/ad, kt/orego nie uda/lo si/e nam omin/a/c. Mianowicie niekt/ore
+ EPS-y s/a poprawnie kompresowane przez GS 2.6, ale ta sama wersja
+ Ghostscript-a nie potrafi ich wy/swietli/c. Podobne objawy
+ obserwowali/smy w przypadku innego pliku w wersji 3.51 Ghostscript-a.
+ Oczywi/scie takie pliki daj/a si/e bez problemu odczyta/c w wy/zszych
+ wersjach GS-a. Jak na razie Ghostscript w wersji 4.03 zachowuje
+ si/e w spos/ob najbardziej stabilny, je/sli chodzi o filtrowanie
+ danych. Gdyby nie /ow nieszcz/esny patent na LZW... No i mo/ze
+ jeszcze k/lopoty z obs/lug/a pami/eci map bitowych (cache?).
+
+ (f) Podsumowuj/ac, stanowczo polecamy stosowanie Ghostscript-a
+ w wersji 4.x lub 5.x (ewentualnie z dokompilowanym algorytmem LZW)
+ oraz GAWK-a w wersji 3.x. GS 4.x jest praktycznie pe/ln/a
+ implementacj/a poziomu drugiego (Level 2) PostScript-u.
+ GAWK 3.x umo/zliwia stosowanie wyra/ze/n regularnych jako
+ separator/ow rekord/ow, co pozwala z kolei na obs/lugiwanie
+ znak/ow ko/nca linii w spos/ob dok/ladnie zgodny z specyfikacj/a
+ PostScript-u. Wersja 3.x GAWK-a jest tak/ze znacznie stabilniejsza
+ od wersji poprzednich.
+
+==========================================================================
+ H I S T O R I A
+==========================================================================
+
+CEP+UNCEP:
+ 0.10 -- 16.03.97 -- pierwsza wersja
+ 0.20 -- 05.04.97 -- usuni/eto kilka wykrytych b/l/ed/ow
+ 0.30 -- 11.04.97 -- wprowadzono now/a metod/e modyfikacji preambu/ly
+ (umo/zliwi/lo to przetwarzanie skomplikowanych
+ prolog/ow), /l/aczenie plik/ow wyj/sciowych
+ przeniesione na poziom PostScript-u (szybsze
+ przetwarzania i mniejsze zu/zycie przestrzeni
+ dyskowej)
+ 0.35 -- 13.04.97 -- dodano komentarze (wersja dwuj/ezyczna)
+ 0.40 -- 14.04.97 -- znacz/aco poprawiono szybko/s/c dzia/lania
+ 0.50 -- 15.04.97 -- /la/ncuchy alokowane s/a statycznie, nie s/a tworzone
+ pliki po/srednie (poprawa szybko/sci dzia/lania
+ oraz zmniejszenie potrzebnej przestrzeni dyskowej)
+ 0.60 -- 19.04.97 -- dodano obs/luge b/l/ed/ow w PostScript-cie,
+ omini/eto kilka b/l/ed/ow GS-a
+ 0.65 -- 20.04.97 -- dodano kod wyj/scia, powsta/la te/z dokumentacja
+ 0.70 -- 21.04.97 -- pierwsza wersja UNCEP-a
+ 0.75 -- 24.04.97 -- usuni/eto k/lopoty z r/o/znymi wersjami ko/nc/ow
+ linii, oraz znacznikiem ko/nca danych szesnastkowych;
+ zebrano i przet/lumaczono dokumentacj/e
+ 1.00 -- 02.05.97 -- bezp/latne udost/epnienie (BachoTeX '97)
+ 1.03 -- 07.01.98 -- uzupe/lnienie dokumentacji, poprawienie odporno/sci
+ pakietu na egzotyczne dane (CEP.AWK)
+
+COP+UNCOP:
+ 0.10 -- 06.04.97 -- pierwsza wersja
+ 0.20 -- 12.04.97 -- budowa programu zosta/la ujednolicona z CEP-em,
+ wstawiono "cvx exec" zamiast b/l/ednego "run"
+ 0.25 -- 13.04.97 -- dodano komentarze (wersja dwuj/ezyczna)
+ 0.30 -- 15.04.97 -- /la/ncuchy alokowane s/a statycznie (znacz/aca
+ poprawa szybko/sci)
+ 0.40 -- 19.04.97 -- dodano obs/luge b/l/ed/ow w PostScript-cie,
+ omini/eto kilka b/l/ed/ow GS-a
+ 0.45 -- 20.04.97 -- dodano kod wyj/scia, powsta/la dokumentacja
+ 0.50 -- 24.04.97 -- usuni/eto k/lopoty z r/o/znymi wersjami ko/nc/ow
+ linii; zebrano i przet/lumaczono dokumentacj/e
+ 1.00 -- 02.05.97 -- bezp/latne udost/epnienie (BachoTeX '97)
+ 1.03 -- 07.01.98 -- uzupe/lnienie dokumentacji, poprawienie odporno/sci
+ pakietu na egzotyczne dane (CEP.AWK)
+
+==========================================================================
+ S /L O W N I C Z E K
+==========================================================================
+
+Ghostscript, GS -- wspania/ly interpreter j/ezyka PostScript, stworzony
+ przez Aladdin Enterprise, dost/epny bezp/latnie na zasadach
+ ,,free public license''; aktualna wersja jest cz/esto lepsza
+ i bardziej stabilna od sprzedawanych za tysi/ace dolar/ow
+ interpreter/ow fotona/swietlarek.
+AWK -- program narz/edziowy, a tak/ze j/ezyk programowania umo/zliwiaj/acy
+ skuteczne i /latwe do zaprogramowania przetwarzania wsadowe
+ plik/ow tekstowych, stworzony w 1977 r. przez Alfreda V. Aho,
+ Petera J. Weinbergera i Briana W. Kernighana.
+GAWK -- Gnu AWK -- dost/epna bezp/latnie na zasadach ,,GNU Free Software
+ Foundation'' implementacja AWK-a, napisana w 1986 r. przez
+ Paula Rubina oraz Jay Fenlasona z pomoc/a Richarda Stallmana.
+GNU -- inicjatywa ,,The Free Software Foundation'' niekomercyjnej
+ organizacji zajmuj/acej si/e tworzeniem i rozpowszechnianiem
+ darmowego oprogramowania. Fundacj/e za/lo/zy/l Richard M. Stallman.
+TeX -- system komputerowego sk/ladu tekstu, stworzony przez
+ Donalda E. Knutha z Uniwersytetu Stanforda, rozpowszechniany
+ jako dobro publiczne.
+DVIPS -- program tworz/acy pliki PostScript-owe z TeX-owych plik/ow DVI,
+ autorstwa Tomasa Rokickiego z Uniwersytetu Stanforda.
+DSC -- Document Structuring Convention -- wyznaczony przez firm/e Adobe
+ standard strukturyzacji plik/ow PostScript-owych.
+ASCII85 -- algorytm kodowania danych binarnych w postaci tekstowej.
+ Koduje ka/zde cztery bajty jako pi/e/c znak/ow z zakresu od ,,%''
+ do ,,u''; cztery bajty zerowe s/a traktowane inaczej i kodowane
+ jako litera ,,z'' (szczeg/o/ly w dokumentacji j/ezyka PostScript,
+ strony 128--130).
+RLE -- run length encoding (kodowanie powtarzaj/acych si/e bajt/ow) --
+ standardowa metoda kompresji danych (szczeg/o/ly w dokumentacji
+ j/ezyka PostScript, strony 133--134).
+LZW -- algorytm kompresji wymy/slony w 1978 roku przez J. Ziva i A. Lempela,
+ poprawiony przez T. Welcha w 1984 r.; w 1985 roku opatentowany
+ w Stanach Zjednoczonych przez firm/e Unisys, zatrudniaj/ac/a Welcha.
+ Firma Unisys uzna/la, /ze implementacje algorytmu sprzed roku 1985
+ s/a wolne od op/laty autorskiej. (Informacja zaczerpni/eta
+ z opracowania Nelsona H. F. Beebe, e-mail beebe@math.utah.edu.)
+DCT -- discrete cosine transform compression (kompresja oparta
+ o numeryczn/a transformat/e kosinusow/a) -- bardzo efektywna,
+ stratna metoda kompresji danych (g/l/ownie graficznych).
+JPEG -- Joint Photographic Experts Group -- organizacja, kt/ora stworzy/la
+ b/ed/acy standardem format zapisu plik/ow oparty na kompresji
+ algorytmem DCT. Filtr PostScript-owy ,,DCTEncoding''
+ jest zgodny ze standardem JPEG.
+GZIP -- program kompresuj/acy stworzony przez GNU Free Software Foundation
+ jako odpowied/x na opatentowanie algorytmu LZW, oparty na bardzo
+ skutecznym i og/olnie dost/epnym algorytmie (wariant algorytmu
+ Lempela i Ziva). Jest on obecnie standardowym narz/edziem kompresji
+ danych w systemach unixowych.
+Flate -- filtr PostScript-u Level 3 wykorzystuj/acy kompresj/e opart/a
+ o ten sam algorytm, kt/ory u/zywany jest przez program GZIP;
+ nazwa pochodzi od angielskich s/l/ow deflate-inflate.
+=======================================================================
+KONIEC ,,CEPCOP_P.INF''
+
diff --git a/support/pstools/cep/cop.awk b/support/pstools/cep/cop.awk
new file mode 100644
index 0000000000..3be8f491a9
--- /dev/null
+++ b/support/pstools/cep/cop.awk
@@ -0,0 +1,143 @@
+# This file belongs to the CEP package | Ten plik nale/zy do pakietu CEP
+# This package is public domain | Pakiet stanowi dobro powszechne
+# For more info see `0CEP_LIC.ENG' | Wi/ecej informacji w ,,0CEP_LIC.POL''
+# ===========================================================================
+# E: "PS" --> "filtered PS" converter
+# input - input file name
+# OUTF - output file name
+# CVM - conversion method
+# TMPSX - temporary PostScript file name
+#
+# P: Konwerter "PS" --> "filtered PS"
+# wej/scie - nazwa pliku konwertowanego
+# OUTF - nazwa pliku wyj/sciowego
+# CVM - metoda konwersji PS-a
+# TMPSX - nazwa tymczasowego pliku PostScriptowego
+
+BEGIN {
+ ver_no=1.03
+ gs_abort="2 2 .quit"
+ RS="\015|\012|\015\012"
+ # preparing temporary files | przygotowywanie plik/ow tymczasowych
+ if (TMPSX=="") TMPSX="tmp.psx"
+ if (CVM!~/[LlRrFfNn]/) CVM=CVM "R" # Default coding and compression method
+ if (CVM!~/[BbHh8]/) CVM=CVM "8" # Domy/slna metoda kodowania i kompresji
+ printf "COP ver. " ver_no ", coding:"
+ if (is_A85()) printf " A85"
+ if (is_HEX()) printf " Hex"
+ if (is_BIN()) printf " Bin"
+ if (is_LZW()) printf ", LZW"
+ if (is_RLE()) printf ", RLE"
+ if (is_ZIP()) printf ", Flate (non-standard in PostScript Level 2!)"
+ print ""
+}
+
+NR==1 && /^%!PS-Adobe/ {hdline=$0}
+
+/^%%BoundingBox:/ {bbline=$0; if (/\(atend\)/) flag=1; if (!flag) exit}
+
+END {
+ # WRITE PostScript ENCODING PROGRAM | TWORZENIE PROGRAMU Postscript-owego
+ out_ps_errorhandler()
+ # create preamble | tworzenie preambu/ly
+ out_ps("(" ps_fname(OUTF) ") (w) file /w_file exch def")
+ out_ps("(" ps_fname(FILENAME) ") (r) file /r_file exch def")
+ out_ps("/p_string 4096 string def")
+ out_ps("/b_string 4096 string def")
+ out_ps("/flushclose {dup flushfile closefile} def")
+ if (hdline=="") hdline="%!PS-Adobe-3.0"
+ hdline=hdline " COP-" ver_no
+ out_ps("w_file (" hdline "\\n) writestring")
+ if (bbline!="") out_ps("w_file (" bbline "\\n) writestring")
+ out_ps("w_file (" banner() "\\n) writestring")
+ out_ps("w_file (" source() "\\n) writestring")
+ # special treatment of the ASCII85 encoded lines looking like DSC comments
+ # dodatkowa obr/obka wierszy (zakodowanych jako ASCII85) zaczynaj/acych
+ # si/e tak jak komentarze DSC
+ if (is_A85()) {
+ out_ps("{pop (%) anchorsearch {pop w_file (%\\n ) writestring} if")
+ out_ps(" {(\n%) search not {exit} if")
+ out_ps(" w_file exch writestring pop w_file (\\n%\\n ) writestring} loop")
+ out_ps(" w_file exch writestring p_string}")
+ out_ps("/NullEncode filter dup")
+ } else out_ps("w_file")
+ # prepare encoding filters | przygotowywanie filtr/ow koduj/acych
+ if (is_A85()) out_ps("/ASCII85Encode filter")
+ if (is_HEX()) out_ps("/ASCIIHexEncode filter")
+ if (is_LZW()) out_ps("dup /LZWEncode filter")
+ if (is_RLE()) out_ps("dup 0 /RunLengthEncode filter")
+ if (is_ZIP()) out_ps("dup /FlateEncode filter")
+ # loop encoding bitmap | p/etla koduj/aca map/e bitow/a
+ out_ps("{r_file b_string readstring not")
+ out_ps("exch 2 index exch writestring")
+ out_ps("{exit} if} loop")
+ if (is_A85()) out_ps("flushclose flushclose")
+ if (is_HEX()) out_ps("flushclose")
+ if (is_LZW()) out_ps("flushclose")
+ if (is_RLE()) out_ps("flushclose")
+ if (is_ZIP()) out_ps("flushclose")
+ # create postamble | tworzenie postambu/ly
+ out_ps("w_file (\\n%%EOF) writestring")
+ out_ps("w_file flushclose r_file closefile quit")
+ printf "."
+}
+
+
+function banner() {return "%%Creator: COP ver. " ver_no " by BOP s.c."}
+
+function ps_fname(s) {gsub(/\\/,"/",s); return(s)}
+
+function out_ps(s) {print s > TMPSX}
+
+function out_ps_errorhandler() {
+ out_ps("/errq {" gs_abort "} def")
+ out_ps("errordict begin ")
+ out_ps("/typecheck {255 string cvs (filter) search")
+ out_ps(" {(\\010!Filter failed) print")
+ out_ps(" ( (ASCII85Encode used with GS version<3.0?)\\n\\007) print}")
+ out_ps(" {(\\010!Something went wrong\\n Error: typecheck\\n\\007) print}")
+ out_ps(" ifelse errq} def")
+ out_ps("/ioerror {(\\010!Input/Output error occurred. (Disk full?)\\n\\007)")
+ out_ps(" print errq} def")
+ out_ps("/handleerror {$error begin (Something went wrong) print")
+ out_ps(" (\\n Error: ) print errorname 255 string cvs print")
+ out_ps(" (\\n\\007) print end errq} def")
+ out_ps("end")
+ #
+ out_ps("systemdict /resourcestatus known not")
+ out_ps("{(\\010!This version of Ghostscript doesn't support required Level 2 features\\n\\007)")
+ out_ps(" print quit} if")
+ if (is_A85()) {
+ check_filter("ASCII85Encode", "ASCII85Encode filter")
+ check_filter("NullEncode", "required Level 2 filters")
+ }
+ if (is_HEX()) check_filter("ASCIIHexEncode", "ASCIIHexEncode filter")
+ if (is_LZW()) check_filter("LZWEncode", "LZWEncode filter")
+ if (is_RLE()) check_filter("RunLengthEncode", "RunLengthEncode filter")
+ if (is_ZIP()) check_filter("FlateEncode", "FlateEncode filter")
+}
+ function check_filter(name, expl) {
+ out_ps("/" name " /Filter resourcestatus {pop pop}")
+ out_ps("{(\\010!This version of Ghostscript doesn't support " expl "\\n\\007)")
+ out_ps(" print errq} ifelse")
+ }
+
+ # searching for the most recent, i.e., active, options
+ # poszukiwanie ostatniej (obowi/azuj/acej) opcji
+function is_BIN() {return (CVM~/[Bb][^Hh8]*$/) }
+function is_A85() {return (CVM~/8[^HhBb]*$/) }
+function is_HEX() {return (CVM~/[Hh][^8Bb]*$/) }
+function is_LZW() {return (CVM~/[Ll][^NnRrFf]*$/) }
+function is_RLE() {return (CVM~/[Rr][^NnLlFf]*$/) }
+function is_ZIP() {return (CVM~/[Ff][^NnLlRr]*$/) }
+
+function source() {
+ s="currentfile"
+ if (is_A85()) s=s " /ASCII85Decode filter"
+ if (is_HEX()) s=s " /ASCIIHexDecode filter"
+ if (is_LZW()) s=s " /LZWDecode filter"
+ if (is_RLE()) s=s " /RunLengthDecode filter"
+ if (is_ZIP()) s=s " /FlateDecode filter"
+ s=s " cvx exec"
+ return s
+}
diff --git a/support/pstools/cep/cop.bat b/support/pstools/cep/cop.bat
new file mode 100644
index 0000000000..4657326d10
--- /dev/null
+++ b/support/pstools/cep/cop.bat
@@ -0,0 +1,49 @@
+:: This file belongs to the CEP package | Ten plik nale/zy do pakietu CEP
+:: This package is public domain | Pakiet stanowi dobro powszechne
+:: For more info see `0CEP_LIC.ENG' | Wi/ecej informacji w ,,0CEP_LIC.POL''
+:: ===========================================================================
+:: E: PS file compression program
+:: This program compresses any PS file using Postscript Level 2 methods.
+::
+:: P: Program do kompresji plik/ow PS.
+:: S/lu/zy on do pakowania oraz kodowania dowolnych plik/ow
+:: PostScriptowych za pomoc/a standardowych algorytm/ow
+:: Postscript-u Level 2.
+::
+@echo off
+if "%2"=="" goto USAGE
+if "%1"=="%2" goto USAGE
+if not exist %1 goto USAGE
+gawk32 -fcop.awk -vTMPSX=tmp.psx -vOUTF=%2 -vCVM=%3%4 %1
+if errorlevel==1 goto DONE
+SET DOS4G=quiet
+if exist tmp.psx call gs386.exe -q -dNODISPLAY tmp.psx
+if exist tmp.psx del tmp.psx
+echo .
+goto DONE
+::
+:USAGE
+echo E: USAGE:
+echo cop input_file output_file [options]
+echo the program recognizes the following options:
+echo 8 -- use ASCII85 coding (default)
+echo b or B -- use binary coding
+echo h or H -- use HEX (hexadecimal) coding
+echo r or R -- use RLE (RunLength) compression (default)
+echo l or L -- use LZW compression
+echo f or F -- use Flate compression (non-standard!)
+echo n or N -- don't compress
+echo (names of input_file and output_file must differ)
+echo.
+echo P: WYWO/LANIE:
+echo cop plik_wej/sciowy plik_wyj/sciowy [opcje]
+echo program rozpoznaje nast/epuj/ace opcje:
+echo 8 -- kodowanie ASCII85 (domy/slnie)
+echo b lub B -- kodowanie binarne
+echo h lub H -- kodowanie HEX -- szesnastkowe
+echo r lub R -- kompresja RLE -- RunLength (domy/slnie)
+echo l lub L -- kompresja LZW
+echo f lub F -- kompresja Flate (niestandardowa!)
+echo n lub N -- bez kompresji
+echo (nazwa pliku wyj/sciowego musi by/c r/o/zna od nazwy pliku wej/sciowego)
+:DONE
diff --git a/support/pstools/cep/uncep.awk b/support/pstools/cep/uncep.awk
new file mode 100644
index 0000000000..c9f79995ed
--- /dev/null
+++ b/support/pstools/cep/uncep.awk
@@ -0,0 +1,140 @@
+# This file belongs to the CEP package | Ten plik nale/zy do pakietu CEP
+# This package is public domain | Pakiet stanowi dobro powszechne
+# For more info see `0CEP_LIC.ENG' | Wi/ecej informacji w ,,0CEP_LIC.POL''
+# ===========================================================================
+# E: "CEP filtered EPS" --> "EPS" converter
+# input - input file name
+# OUTF - output file name
+# TMPSX - temporary PostScript file name
+#
+# P: Konwerter "CEP filtered EPS" --> "EPS"
+# wej/scie - nazwa pliku konwertowanego
+# OUTF - nazwa pliku wyj/sciowego
+# TMPSX - nazwa tymczasowego pliku PostScriptowego
+
+BEGIN {# preparing temporary files | przygotowywanie plik/ow tymczasowych
+ ver_no=1.03
+ gs_abort="2 2 .quit"
+ chop_EOD=1
+ if (TMPSX=="") TMPSX="tmp.psx"
+ flag="begin"
+}
+
+ # check carefully whether the file to be processed was created by CEP
+ # sprawd/xmy staranne czy mamy do czynienia z plikiem stworzonym przez CEP-a
+
+{l=$0 "\n"} # l is a candidate for a prolog line
+flag~"begin" && /^%%Creator: CEP/ {flag="cep"; l=""} # ignore CEP comment
+flag~"cep" && /^%UNCEPInfo:/ && NF==5 {
+ # store CEP data, ignore CEP comment
+ pre_lines=0+$2; buff_num=0+$3; buff_len=0+$4; pos_lines=0+$5
+ flag="uncep"; l=""
+}
+flag~"uncep" && /^\/_fltrd_file currentfile .+ \/_read_string .+ def$/ {
+ # store CEP decoding scheme, ignore CEP line
+ decodeline=$0; flag="good"; l=""
+}
+{prolog=prolog l} # lengthen prolog
+flag!~"uncep|good" && /^[^%]/ {exit} # emergency exit (CEP comment not found
+ # in DSC comment block)
+flag~"uncep|good" && NR==pre_lines {exit} # exit after prolog
+
+END {
+ # error handling | obs/luga b/l/ed/ow
+ if (flag!~"good") errmessage("not a CEP file",1)
+ if (!is_A85() && !is_HEX())
+ errmessage("CEP file was modified (strange coding), can't uncompress",4)
+ printf "UNCEP ver. " ver_no ", decoding:"
+ if (is_A85()) printf " A85"
+ if (is_HEX()) printf " Hex"
+ if (is_LZW()) printf ", LZW"
+ if (is_RLE()) printf ", RLE"
+ if (is_ZIP()) printf ", Flate"
+ print ""
+
+ # restore preamble of EPS file
+ # odtworzenie preambu/ly pliku EPS
+
+ if (gsub(/_fltrd_file/,"currentfile",prolog)==0)
+ errmessage("CEP file was modified, can't uncompress",4)
+ if (gsub(/_read_string/,"readhexstring",prolog)==0)
+ errmessage("CEP file was modified, can't uncompress",4)
+ gsub(/%/,"%%",prolog) # neutralizing printf | podmiana dla printf
+
+ # WRITE PostScript ENCODING PROGRAM | TWORZENIE PROGRAMU Postscript-owego
+ out_ps("(" ps_fname(OUTF) ") (w) file /w_file exch def")
+ out_ps("(" ps_fname(FILENAME) ") (r) file /r_file exch def")
+ out_ps("/l_string 255 string def")
+ out_ps("/p_string 4096 string def")
+ out_ps("/b_string " buff_len " string def")
+ out_ps("/flushclose {dup flushfile closefile} def")
+ # copy preamble | przepisywanie preambu/ly
+ out_ps(pre_lines " {r_file l_string readline pop pop} repeat")
+ out_ps(pre_lines-3 " {currentfile l_string readline pop")
+ out_ps("w_file exch writestring w_file (\\n) writestring} repeat")
+ out_ps_block(prolog)
+ out_ps("%--- PROLOG END | KONIEC PROLOGU")
+ # prepare decoding | przygotowywanie filtr/ow dekoduj/acych
+ if (is_A85()) out_ps("r_file /ASCII85Decode filter")
+ if (is_HEX()) out_ps("r_file /ASCIIHexDecode filter")
+ if (is_LZW()) out_ps("dup /LZWDecode filter")
+ if (is_RLE()) out_ps("dup /RunLengthDecode filter")
+ if (is_ZIP()) out_ps("dup /FlateDecode filter")
+ out_ps("/d_file exch def")
+ if (chop_EOD) {# remove EOD mark
+ out_ps("{not {dup length 1 sub 0 exch getinterval} if")
+ out_ps(" w_file exch writestring p_string}")
+ } else out_ps("w_file")
+ out_ps("/ASCIIHexEncode filter")
+ # loop decoding the EPS file | p/etla dekoduj/aca plik EPS
+ out_ps(buff_num " {dup d_file b_string")
+ out_ps(" readstring pop writestring} repeat")
+ out_ps("flushclose d_file closefile")
+ if (is_LZW() || is_RLE() || is_ZIP()) out_ps("closefile")
+ # copy postamble | przepisanie postambu/ly
+ out_ps(pos_lines+1 " {r_file l_string readline pop")
+ out_ps("w_file exch writestring w_file (\\n) writestring} repeat")
+ out_ps("w_file flushclose r_file closefile quit")
+ printf "."
+}
+
+function ps_fname(s) {gsub(/\\/,"/",s); return(s)}
+
+function out_ps(s) {print s > TMPSX}
+function out_ps_block(block) {printf block > TMPSX}
+
+function out_ps_errorhandler() {
+ out_ps("/errq {" gs_abort "} def")
+ out_ps("errordict begin ")
+ out_ps("/ioerror {(\\010!Input/Output error occurred. (Disk full?)\\n\\007)")
+ out_ps(" print errq} def")
+ out_ps("/handleerror {$error begin (Something went wrong) print")
+ out_ps(" (\\n Error: ) print errorname 255 string cvs print")
+ out_ps(" (\\n\\007) print end errq} def")
+ out_ps("end")
+ #
+ out_ps("systemdict /resourcestatus known not")
+ out_ps("{(\\010!This version of Ghostscript doesn't support required Level 2 features\\n\\007)")
+ out_ps(" print quit} if")
+ if (is_A85()) check_filter("ASCII85Decode", "ASCII85Decode filter")
+ if (is_HEX()) check_filter("ASCIIHexDecode", "ASCIIHexDecode filter")
+ if (is_LZW()) check_filter("LZWDecode", "LZWDecode filter")
+ if (is_RLE()) check_filter("RunLengthDecode", "RunLengthDecode filter")
+ if (is_ZIP()) check_filter("FlateDecode", "FlateDecode filter")
+}
+ function check_filter(name, expl) {
+ out_ps("/" name " /Filter resourcestatus {pop pop}")
+ out_ps("{(\\010!This version of Ghostscript doesn't support " expl "\\n\\007)")
+ out_ps(" print errq} ifelse")
+ }
+
+function errmessage(errname, errnum) {
+ print "UNCEP ERROR:", errname "\007"; exit(errnum)
+}
+
+ # determine file decoding method | ustalanie sposobu dekodowania pliku
+function is_A85() {return (decodeline~/\/ASCII85Decode/)}
+function is_HEX() {return (decodeline~/\/ASCIIHexDecode/)}
+function is_LZW() {return (decodeline~/\/LZWDecode/)}
+function is_RLE() {return (decodeline~/\/RunLengthDecode/)}
+function is_ZIP() {return (decodeline~/\/FlateDecode/)}
diff --git a/support/pstools/cep/uncep.bat b/support/pstools/cep/uncep.bat
new file mode 100644
index 0000000000..20adbd6ed8
--- /dev/null
+++ b/support/pstools/cep/uncep.bat
@@ -0,0 +1,31 @@
+:: This file belongs to the CEP package | Ten plik nale/zy do pakietu CEP
+:: This package is public domain | Pakiet stanowi dobro powszechne
+:: For more info see `0CEP_LIC.ENG' | Wi/ecej informacji w ,,0CEP_LIC.POL''
+:: ===========================================================================
+:: E: A decompression program of EPS files compressed with CEP
+::
+:: P: Program do rozpakowywania plik/ow EPS spakowanych za pomoc/a CEP-a
+::
+@echo off
+if "%2"=="" goto USAGE
+if "%1"=="%2" goto USAGE
+if not exist %1 goto USAGE
+gawk32 -funcep.awk -vTMPSX=tmp.psx -vOUTF=%2 %1
+if errorlevel==1 goto DONE
+SET DOS4G=quiet
+if exist tmp.psx call gs386.exe -q -dNODISPLAY tmp.psx
+if exist tmp.psx del tmp.psx
+echo .
+goto DONE
+::
+:USAGE
+echo E: USAGE:
+echo uncep input_file output_file
+echo (decompression and decoding method is taken from input file;
+echo names of input_file and output_file must differ)
+echo.
+echo P: WYWO/LANIE:
+echo uncep plik_wej/sciowy plik_wyj/sciowy
+echo (metoda dekodowania jest ustalana na postawie pliku wej/sciowego;
+echo nazwa pliku wyj/sciowego musi by/c r/o/zna od nazwy pliku wej/sciowego)
+:DONE
diff --git a/support/pstools/cep/uncop.awk b/support/pstools/cep/uncop.awk
new file mode 100644
index 0000000000..6ea75e5f72
--- /dev/null
+++ b/support/pstools/cep/uncop.awk
@@ -0,0 +1,103 @@
+# This file belongs to the CEP package | Ten plik nale/zy do pakietu CEP
+# This package is public domain | Pakiet stanowi dobro powszechne
+# For more info see `0CEP_LIC.ENG' | Wi/ecej informacji w ,,0CEP_LIC.POL''
+# ===========================================================================
+# E: "COP filtered PS" --> "PS" converter
+# input - input file name
+# OUTF - output file name
+# TMPSX - temporary PostScript file name
+#
+# P: Konwerter "COP filtered PS" --> "PS"
+# wej/scie - nazwa pliku konwertowanego
+# OUTF - nazwa pliku wyj/sciowego
+# TMPSX - nazwa tymczasowego pliku PostScriptowego
+
+BEGIN {# preparing temporary files | przygotowywanie plik/ow tymczasowych
+ ver_no=1.03
+ gs_abort="2 2 .quit"
+ if (TMPSX=="") TMPSX="tmp.psx"
+ flag="was_begin"
+}
+
+ # check carefully whether the file to be processed was created by COP
+ # sprawd/xmy staranne czy mamy do czynienie z plikiem stworzonym przez COP-a
+
+/^%!PS-Adobe.* COP/ && flag~"was_begin" {flag="adobe"}
+/^%%BoundingBox/ && flag~"was_adobe" {flag="bbox"}
+/^%%Creator: COP/ && flag~"was_(adobe|bbox)" {flag="cops"}
+/^currentfile.*cvx exec$/ && flag~"was_cops" {decodeline=$0; exit}
+flag~"was" {exit}
+{flag="was_" flag}
+
+END {
+ # error handling | obs/luga b/l/ed/ow
+ if (decodeline=="") errmessage("not a COP file",1)
+ printf "UNCOP ver. " ver_no ", decoding:"
+ if (is_A85()) printf " A85"
+ if (is_HEX()) printf " Hex"
+ if (!is_HEX() && !is_A85()) printf " Bin"
+ if (is_LZW()) printf ", LZW"
+ if (is_RLE()) printf ", RLE"
+ if (is_ZIP()) printf ", Flate"
+ print ""
+ # WRITE PostScript ENCODING PROGRAM | TWORZENIE PROGRAMU Postscript-owego
+ out_ps_errorhandler()
+ # skipping preamble | pomijanie preambu/ly
+ out_ps("/b_string 4096 string def")
+ out_ps("(" ps_fname(FILENAME) ") (r) file")
+ for (i=1; i<=NR; ++i) out_ps("dup 255 string readline pop pop")
+ # prepare decoding | przygotowywanie filtr/ow dekoduj/acych
+ if (is_A85()) out_ps("/ASCII85Decode filter")
+ if (is_HEX()) out_ps("/ASCIIHexDecode filter")
+ if (is_LZW()) out_ps("/LZWDecode filter")
+ if (is_RLE()) out_ps("/RunLengthDecode filter")
+ if (is_ZIP()) out_ps("/FlateDecode filter")
+ out_ps("(" ps_fname(OUTF) ") (w) file")
+ out_ps("exch")
+ # loop decoding the Postscript file | p/etla dekoduj/aca plik Postscriptowy
+ out_ps("{dup b_string readstring")
+ out_ps("not exch 3 index exch")
+ out_ps("writestring {exit} if} loop")
+ out_ps("closefile closefile quit")
+ printf "."
+}
+
+function ps_fname(s) {gsub(/\\/,"/",s); return(s)}
+
+function out_ps(s) {print s > TMPSX}
+
+function out_ps_errorhandler() {
+ out_ps("/errq {" gs_abort "} def")
+ out_ps("errordict begin ")
+ out_ps("/ioerror {(\\010!Input/Output error occurred. (Disk full?)\\n\\007)")
+ out_ps(" print errq} def")
+ out_ps("/handleerror {$error begin (Something went wrong) print")
+ out_ps(" (\\n Error: ) print errorname 255 string cvs print")
+ out_ps(" (\\n\\007) print end errq} def")
+ out_ps("end")
+ #
+ out_ps("systemdict /resourcestatus known not")
+ out_ps("{(\\010!This version of Ghostscript doesn't support required Level 2 features\\n\\007)")
+ out_ps(" print quit} if")
+ if (is_A85()) check_filter("ASCII85Decode", "ASCII85Decode filter")
+ if (is_HEX()) check_filter("ASCIIHexDecode", "ASCIIHexDecode filter")
+ if (is_LZW()) check_filter("LZWDecode", "LZWDecode filter")
+ if (is_RLE()) check_filter("RunLengthDecode", "RunLengthDecode filter")
+ if (is_ZIP()) check_filter("FlateDecode", "FlateDecode filter")
+}
+ function check_filter(name, expl) {
+ out_ps("/" name " /Filter resourcestatus {pop pop}")
+ out_ps("{(\\010!This version of Ghostscript doesn't support " expl "\\n\\007)")
+ out_ps(" print errq} ifelse")
+ }
+
+function errmessage(errname, errnum) {
+ print "UNCOP ERROR:", errname "\007"; exit(errnum)
+}
+
+ # determine file decoding method | ustalanie sposobu dekodowania pliku
+function is_A85() {return (decodeline~/\/ASCII85Decode/)}
+function is_HEX() {return (decodeline~/\/ASCIIHexDecode/)}
+function is_LZW() {return (decodeline~/\/LZWDecode/)}
+function is_RLE() {return (decodeline~/\/RunLengthDecode/)}
+function is_ZIP() {return (decodeline~/\/FlateDecode/)}
diff --git a/support/pstools/cep/uncop.bat b/support/pstools/cep/uncop.bat
new file mode 100644
index 0000000000..f732d7ef86
--- /dev/null
+++ b/support/pstools/cep/uncop.bat
@@ -0,0 +1,31 @@
+:: This file belongs to the CEP package | Ten plik nale/zy do pakietu CEP
+:: This package is public domain | Pakiet stanowi dobro powszechne
+:: For more info see `0CEP_LIC.ENG' | Wi/ecej informacji w ,,0CEP_LIC.POL''
+:: ===========================================================================
+:: E: A decompression program of PS files compressed with COP
+::
+:: P: Program do rozpakowywania plik/ow PS spakowanych za pomoc/a COP-a
+::
+@echo off
+if "%2"=="" goto USAGE
+if "%1"=="%2" goto USAGE
+if not exist %1 goto USAGE
+gawk32 -funcop.awk -vTMPSX=tmp.psx -vOUTF=%2 %1
+if errorlevel==1 goto DONE
+SET DOS4G=quiet
+if exist tmp.psx call gs386.exe -q -dNODISPLAY tmp.psx
+if exist tmp.psx del tmp.psx
+echo .
+goto DONE
+::
+:USAGE
+echo E: USAGE:
+echo uncop input_file output_file
+echo (decompression and decoding method is taken from input file;
+echo names of input_file and output_file must differ)
+echo.
+echo P: WYWO/LANIE:
+echo uncop plik_wej/sciowy plik_wyj/sciowy
+echo (metoda dekodowania jest ustalana na postawie pliku wej/sciowego;
+echo nazwa pliku wyj/sciowego musi by/c r/o/zna od nazwy pliku wej/sciowego)
+:DONE
diff --git a/support/pstools/ps_conv/0ps_conv.doc b/support/pstools/ps_conv/0ps_conv.doc
new file mode 100644
index 0000000000..27cdee656c
--- /dev/null
+++ b/support/pstools/ps_conv/0ps_conv.doc
@@ -0,0 +1,92 @@
+This file belongs to the PS_CONV package.
+
+-----------------------------------------------------------------------------
+
+The package PS_CONV belongs to the public domain. You are entitled to do with
+the files of which it consists whatever you wish. If you alter a file,
+however, please remove the line containing the comment
+
+ `This file belongs to the PS_CONV package.'
+
+in order to avoid a mess.
+
+-----------------------------------------------------------------------------
+
+Authors: P. Pianowski and B. Jackowski
+Address: BOP s.c., ul. Piastowska 70, 80-363 Gda\'nsk, Poland
+ bop@bop.com.pl
+
+-----------------------------------------------------------------------------
+
+The kernel of the package is a PostScript program, PS_CONV.PS, for converting
+one-page PostScript files into EPS (encapsulated PostScript) files readable
+by CorelDRAW!(R), Adobe Illustrator(TM) and Fontographer(R). The current
+version is to be used with the Ghostscript interpreter.
+
+The main features of the current verion of the converter are as follows:
+
+1) If a multi-page document is supplied, only the first page is processed.
+2) Bitmaps are ignored.
+3) Fonts are always converted to curves (for Ghostscript ver. < 3 outlines
+ of the Adobe Type 1 fonts are approximated by polygons).
+4) If the size of a converted object differs essentially from A4 page,
+ an internal parameter of PS_CONV, SCALE (by default SCALE=10),
+ may require manual tuning. For larger pictures SCALE should be smaller,
+ otherwise a `numeric exeption' error may occur; for tiny pictures it
+ can be enlarged. Its value can be passed, e.g., in a command line:
+ ... -dSCALE=100 ...
+5) So far PS_CONV was tested only with Ghostscript interpreter
+
+-----------------------------------------------------------------------------
+
+The package consists of the following files:
+
+ 0PS_CONV.DOC this file
+ PS_CONV.PS the ``engine''
+ GC.BAT sample DOS batch file (making use of GS386);
+ to be adjusted to a particular installation
+ GC.PAR parameters for Ghostscript for the converting session
+ GC_HEAD.PS a header, prepended to the result of the conversion
+ GC_TAIL.PS a trailer, appended to the result of the conversion
+
+Additionally, SHOWPAGE.PS file is referred to. It belongs to the standard
+Ghostscript distribution.
+
+-----------------------------------------------------------------------------
+
+LOCATION OF FILES (DOS)
+
+It is assumed that all the package is placed in the directory C:\PS_CONV.
+If another destination place is required, the following files should be
+adjusted:
+
+ GC.BAT
+ GC.PAR
+
+Ghostscript interpreter is assumed to be in a directory specified by the
+DOS environment variable PATH.
+
+-----------------------------------------------------------------------------
+
+HISTORY:
+
+% ver. 0.50, Friday, October 27th, 1995:
+% * first official public domain release
+% October 30th, 1995:
+% * GC.BAT and GC.PAR touched
+% ver. 0.52, Wednesday, April 10th, 1996
+% * oper_kind added to degenerated paths (i.e. containing only
+% `m' operation)
+% * paper format commands neutralized
+% * new parameter called ACLEV added; decimal numbers are printed with
+% precision PREC (default PREC=3; max. 3 digits follow period)
+% ver. 0.53, Friday, November 8th, 1996
+% * the bug in `print_rounded' fixed: numbers of the form `0.0123' i.e.
+% with leading zeros following the period were badly printed.
+% ver. 0.54, Wednesday, January 5th, 2000
+% * the file `gc_head' has been improved, paths beeng eofilled
+% and eoclipped are closed explicity
+
+-----------------------------------------------------------------------------
+
+END OF THE 0PS_CONV.DOC FILE
diff --git a/support/pstools/ps_conv/README b/support/pstools/ps_conv/README
new file mode 120000
index 0000000000..ce0e665d5f
--- /dev/null
+++ b/support/pstools/ps_conv/README
@@ -0,0 +1 @@
+0ps_conv.doc \ No newline at end of file
diff --git a/support/pstools/ps_conv/gc.bat b/support/pstools/ps_conv/gc.bat
new file mode 100644
index 0000000000..deafbdc1ef
--- /dev/null
+++ b/support/pstools/ps_conv/gc.bat
@@ -0,0 +1,29 @@
+@echo off
+:: DOS batch for converting PS files into ``canonical'' EPS files
+:: using Ghostscript
+if "%2" == "" goto USAGE
+if "%1" == "%2" goto BAD
+tm START
+echo.
+if "%4" == "" goto NOOFF
+gs386 @c:/ps_conv/gc.par -dDOS -dXOFF=%3 -dYOFF=%4 ps_conv.ps %1 showpage.ps
+goto CONT
+:NOOFF
+gs386 @c:/ps_conv/gc.par -dDOS ps_conv.ps %1 showpage.ps
+:CONT
+if exist !ps_exp1.ps goto MERGE
+goto END
+:MERGE
+copy !ps_exp2.ps + c:\ps_conv\gc_head.ps + !ps_exp1.ps + c:\ps_conv\gc_tail.ps %2 /b
+:ENDING
+del !ps_exp1.ps
+del !ps_exp2.ps
+:END
+echo.
+tm STOP
+goto DONE
+:BAD
+echo INPUT AND OUTPUT FILES MUST HAVE DIFFERENT NAMES!
+:USAGE
+echo USAGE: gc input-file-name output-file-name [X-offset Y-offset]
+:DONE
diff --git a/support/pstools/ps_conv/gc.par b/support/pstools/ps_conv/gc.par
new file mode 100644
index 0000000000..1b92850cd5
--- /dev/null
+++ b/support/pstools/ps_conv/gc.par
@@ -0,0 +1 @@
+-I.;..;c:/ps_conv/ -sPAPERSIZE=a4 -q -dNODISPLAY -dNOCACHEDEVICE
diff --git a/support/pstools/ps_conv/gc_head.ps b/support/pstools/ps_conv/gc_head.ps
new file mode 100644
index 0000000000..adac358739
--- /dev/null
+++ b/support/pstools/ps_conv/gc_head.ps
@@ -0,0 +1,32 @@
+%%BeginProlog
+/GSexport 100 dict def GSexport begin
+/h {closepath} def
+/m {moveto} def
+/c {curveto} def
+/l {lineto} def
+/k {setcmykcolor} def
+/K {setcmykcolor} def
+/*u {/oper_kind -1 def} def
+/*U {*U*f *U*d *U*c} def
+/f {closepath /oper_kind 0 def} def
+/*U*f {0 oper_kind eq {eofill} if} def
+/s {closepath /oper_kind 1 def} def
+/S {/oper_kind 1 def} def
+/*U*d {1 oper_kind eq {stroke} if} def
+/W {} def
+/n {closepath /oper_kind 2 def} def
+/*U*c {2 oper_kind eq {eoclip newpath} if} def
+/w {setlinewidth} def
+/j {setlinejoin} def
+/J {setlinecap} def
+/M {setmiterlimit} def
+/d {setdash} def
+/setcmykcolor where {pop}
+ {/setcmykcolor {1 sub /mf exch def
+ 3 {mf add neg dup 0 lt {pop 0} if 3 1 roll} repeat
+ setrgbcolor} def} ifelse
+/q {gsave} def
+/Q {grestore} def
+%%EndProlog
+%%BeginSetup
+%%EndSetup
diff --git a/support/pstools/ps_conv/gc_tail.ps b/support/pstools/ps_conv/gc_tail.ps
new file mode 100644
index 0000000000..0a620aec76
--- /dev/null
+++ b/support/pstools/ps_conv/gc_tail.ps
@@ -0,0 +1,4 @@
+%%Trailer
+end
+showpage
+
diff --git a/support/pstools/ps_conv/ps_conv.ps b/support/pstools/ps_conv/ps_conv.ps
new file mode 100644
index 0000000000..103dc72ac3
--- /dev/null
+++ b/support/pstools/ps_conv/ps_conv.ps
@@ -0,0 +1,286 @@
+%!PS-Adobe-2.0
+%%Subject: PostScript prolog for converting PostScript files into
+%%Subject: a canonical EPS form, acceptable by such programs as
+%%Subject: CorelDRAW!(R), Adobe Illustrator(TM) and Fontographer(R).
+%%Copyright: (c) BOP s.c. 1993--1999
+%%Public domain
+%%Version: 0.54
+%%LastUpdate: Wednesday, January 5th, 2000
+%%BeginProcSet: ps_conv.ps
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Authors: P. Pianowski and B. Jackowski
+% Address: BOP s.c., ul. Piastowska 70, 80-363 Gda\'nsk, Poland
+% bop@bop.com.pl
+% History:
+% ver. 0.50, Friday, October 27th, 1995:
+% * first official public domain release
+% October 30th, 1995:
+% * GC.BAT and GC.PAR touched
+% ver. 0.52, Wednesday, April 10th, 1996
+% * oper_kind added to degenerated paths (i.e. containing only
+% `m' operation)
+% * paper format commands neutralized
+% * new parameter called PREC added; decimal numbers are printed with
+% precision PREC (default PREC=3; max. 3 digits follow period)
+% ver. 0.53, Friday, November 8th, 1996
+% * the bug in `print_rounded' fixed: numbers of the form `0.0123' i.e.
+% with leading zeros following the period were badly printed.
+% ver. 0.54, Wednesday, January 5th, 2000
+% * the file `gc_head' has been improved, paths beeng eofilled
+% and eoclipped are closed explicity
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+/ExportDict 100 dict def ExportDict begin
+%
+% command line parameters:
+systemdict /SCALE known {/SCALE SCALE def} {/SCALE 10 def} ifelse
+systemdict /XOFF known {/XOFF XOFF def} {/XOFF 0 def} ifelse
+systemdict /YOFF known {/YOFF YOFF def} {/YOFF 0 def} ifelse
+systemdict /DASHED known {/DASHED true def} {/DASHED false def} ifelse
+systemdict /DOS known
+ {/print_new_line {<0D0A> print} def}
+ {/print_new_line {<0A> print} def} ifelse
+systemdict /PREC known {/PREC PREC def} {/PREC 3 def} ifelse
+% end of parameters
+%
+statusdict begin
+ /letter {} def
+ /note {} def
+ /legal {} def
+ /a3 {} def
+ /a4 {} def
+ /a5 {} def
+ /a6 {} def
+ /b4 {} def
+ /b5 {} def
+ /flsa {} def
+ /flse {} def
+ /halfletter {} def
+ /11x17 {} def
+ /ledger {} def
+ /setpageparams {pop pop pop pop} def
+ /setpage {pop pop pop} def
+end
+%
+/val_str 20 string def
+/epsilon 0.001 def
+SCALE dup matrix scale setmatrix
+/curr_matr matrix currentmatrix def
+/default_matr curr_matr def
+/xl 100000 def
+/yl 100000 def
+/xh -100000 def
+/yh -100000 def
+/save_bb {ExportDict begin xl yl xh yh end} def
+/restore_bb {ExportDict begin /yh exch def /xh exch def
+ /yl exch def /xl exch def end} def
+/ori_restore /restore load def
+/restore {ExportDict begin save_bb 5 -1 roll ori_restore restore_bb end} def
+%
+% <x> <y> set_bb <x> <y>
+/set_bb {ExportDict begin
+ dup yl lt {dup /yl exch def} if
+ dup yh gt {dup /yh exch def} if
+ exch
+ dup xl lt {dup /xl exch def} if
+ dup xh gt {dup /xh exch def} if
+ exch
+ end} def
+%
+/accuracy 10 PREC neg exp def
+/accuracy_mask (00000000000000000000000000000000000000000000000)
+ 0 PREC 1 add getinterval def
+/print_rounded {ExportDict begin
+ dup abs 0.000001 lt {pop (0) print} {accuracy div round
+ dup abs 16#7FFFFFFF gt {pop (INTEGER OUT of RANGE!\n) ori_print quit} if
+ cvi
+ /minus_sign false def dup 0 lt {neg /minus_sign true def} if
+ %
+ dup /int_to_pull exch def /dig_to_pull 0 def
+ {int_to_pull 0 eq {exit} if
+ /mod_to_pull int_to_pull 10 mod def
+ mod_to_pull 0 eq {/dig_to_pull dig_to_pull 1 add def
+ /int_to_pull int_to_pull 10 idiv def} {exit} ifelse} loop
+ %
+ /fractional_dig PREC dig_to_pull sub 0 max def
+ minus_sign {(-) print} if
+ val_str cvs
+ %
+% dup length PREC le {/leading_zeros accuracy_mask def %% !! ERROR
+ dup length PREC le {/leading_zeros PREC 1 add string def
+ leading_zeros 0 accuracy_mask putinterval
+ %
+ leading_zeros exch
+ dup length PREC 1 add exch sub exch putinterval leading_zeros} if
+ dup dup length PREC sub 0 exch getinterval print
+ fractional_dig 0 eq {pop} {(.) print
+ dup length PREC sub fractional_dig getinterval
+ print} ifelse} ifelse end} def
+/print_scaled_x {ExportDict begin SCALE div XOFF sub print_rounded end} def
+/print_scaled_y {ExportDict begin SCALE div YOFF sub print_rounded end} def
+%
+% <s0>..<sn> <r> n_print
+/n_print {ExportDict begin -1 1 {-1 roll print_rounded ( ) print} for end} def
+%
+/p_trans {ExportDict begin /r_param exch def
+ r_param -1 roll dup /trans_x exch def r_param 1 roll
+ /r_param r_param 1 sub def
+ r_param -1 roll dup /trans_y exch def r_param 1 roll
+ trans_x trans_y curr_matr transform
+ set_bb
+ exch
+ print_scaled_x ( ) print
+ print_scaled_y ( ) print
+ end} def
+%
+/check_point {ExportDict begin
+ x_1 curr_x sub dup mul
+ y_1 curr_y sub dup mul add sqrt epsilon ge
+ end} def
+%
+/ori_currentcmykcolor /currentcmykcolor load def
+/ori_gsave /gsave load def
+/ori_grestore /grestore load def
+/ori_moveto /moveto load def
+/ori_curveto /curveto load def
+/ori_lineto /lineto load def
+/ori_closepath /closepath load def
+%
+/my_moveto {ExportDict begin
+ matrix currentmatrix curr_matr ne {/curr_matr matrix currentmatrix def} if
+ /y_start exch def
+ /x_start exch def
+ /curr_x x_start def
+ /curr_y y_start def
+ oper_to_send {oper_kind dup (s) eq {pop (S)} if print print_new_line} if
+ /oper_to_send true def
+ curr_x curr_y
+ 2 p_trans
+ (m) print print_new_line
+ ori_moveto
+ end} def
+/my_curveto {ExportDict begin
+ /y_1 exch def /x_1 exch def
+ check_point
+ {
+ x_1 y_1
+ 6 p_trans
+ 4 p_trans
+ 2 p_trans
+ (c) print print_new_line
+ /curr_x x_1 def
+ /curr_y y_1 def
+ }
+ {x_1 y_1} ifelse
+ ori_curveto
+ end} def
+/my_lineto {ExportDict begin
+ /y_1 exch def /x_1 exch def
+ check_point
+ {
+ x_1 y_1
+ 2 p_trans
+ (l) print print_new_line
+ /curr_x x_1 def
+ /curr_y y_1 def
+ }
+ {x_1 y_1} ifelse
+ ori_lineto
+ end} def
+/my_closepath {ExportDict begin
+ curr_x curr_y y_start ne exch x_start ne or
+ {x_start y_start 2 p_trans (l) print print_new_line ori_lineto} if
+ oper_kind print print_new_line
+ /oper_to_send false def
+ ori_closepath
+ end} def
+/gsave {ExportDict begin (q) print print_new_line ori_gsave end} def
+/grestore {ExportDict begin(Q) print print_new_line ori_grestore end} def
+%
+/show {ExportDict begin
+ ori_gsave
+ currentfont [1 0 0 1 0 0] makefont setfont
+ false charpath currentpoint
+ (*u) print print_new_line
+ ori_currentcmykcolor 4 n_print (k) print print_new_line
+ /oper_kind (f) def /oper_to_send false def
+ {my_moveto} {my_lineto} {my_curveto} {my_closepath} pathforall
+ oper_to_send {oper_kind print print_new_line} if
+ (*U) print print_new_line
+ ori_grestore
+ newpath moveto
+ end} def
+/eofill {ExportDict begin
+ ori_gsave
+ closepath
+ (*u) print print_new_line
+ ori_currentcmykcolor 4 n_print (k) print print_new_line
+ /oper_kind (f) def /oper_to_send false def
+ {my_moveto} {my_lineto} {my_curveto} {my_closepath} pathforall
+ oper_to_send {oper_kind print print_new_line} if
+ (*U) print print_new_line
+ ori_grestore newpath
+ end} def
+/eoclip {ExportDict begin
+ ori_gsave
+ closepath
+ (*u) print print_new_line
+ /oper_kind (h W n) def /oper_to_send false def
+ {my_moveto} {my_lineto} {my_curveto} {my_closepath} pathforall
+ oper_to_send {oper_kind print print_new_line} if
+ (*U) print print_new_line
+ ori_grestore newpath
+ end} def
+/local_transform{ExportDict begin 0
+ default_matr matrix invertmatrix matrix currentmatrix matrix concatmatrix
+ aload pop pop pop 0 0 6 array astore transform
+ dup mul exch dup mul add sqrt
+ end} def
+/print_local_transform{ExportDict begin local_transform print_rounded end} def
+/n_print_local {ExportDict begin
+ -1 1 {-1 roll print_local_transform ( ) print} for end} def
+/stroke {ExportDict begin
+ ori_gsave
+ (*u) print print_new_line
+ currentlinewidth print_local_transform ( w ) print
+ currentlinejoin print_rounded ( j ) print
+ currentlinecap print_rounded ( J ) print
+ currentmiterlimit local_transform dup 1 lt {pop 1} if print_rounded
+ ( M ) print
+ DASHED {
+ print_new_line
+ currentdash exch dup length /dashlength exch def
+ aload pop ([) print dashlength n_print_local (] ) print print_rounded
+ ( d) print} if
+ print_new_line
+ ori_currentcmykcolor 4 n_print (K) print print_new_line
+ /oper_kind (s) def /oper_to_send false def
+ {my_moveto} {my_lineto} {my_curveto} {my_closepath} pathforall
+ oper_to_send {(S) print print_new_line} if
+ (*U) print print_new_line
+ ori_grestore newpath
+ end} def
+/fill /eofill load def
+/clip /eoclip load def
+%
+/out_file (!ps_exp1.ps) (w) file def
+/showpage {ExportDict begin
+ out_file flushfile
+ out_file closefile
+ /out_file (!ps_exp2.ps) (w) file def
+ (%!PS-Adobe-2.0 EPSF-2.0) print print_new_line
+ (%%Creator: GhostScript rev. ) print revision print_rounded print_new_line
+ (%%BoundingBox: ) print
+ xl print_scaled_x ( ) print
+ yl print_scaled_y ( ) print
+ xh print_scaled_x ( ) print
+ yh print_scaled_y print_new_line
+ (%%EndComments) print print_new_line
+ out_file flushfile
+ out_file closefile
+ quit
+ end} def
+/ori_print /print load def
+/print {ExportDict begin out_file exch writestring end} def
+end
+%%EndProcSet: ps_conv.ps
+ExportDict begin
diff --git a/support/pstools/tif2eps/readme.eng b/support/pstools/tif2eps/readme.eng
new file mode 100644
index 0000000000..cc8e5ebd5b
--- /dev/null
+++ b/support/pstools/tif2eps/readme.eng
@@ -0,0 +1,53 @@
+TIF2EPS ver. 0.79, 1 Mar 2005.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License. See:
+http://www.fsf.org/licenses/gpl.txt
+
+AUTHORS: Bogu\l{}aw Jackowski, Piotr Pianowski, Piotr Strzelczyk
+Mail: BOP s.c., ul. Bora-Komorowskiego 24, 80-377 Gda\'nsk, Poland
+Email: P.Strzelczyk@GUST.org.pl, bop@bop.com.pl
+
+
+TIF2EPS is a PostScript program for the conversion of TIFF files (ver. 6.0)
+to EPS ones. Compression (LZW, CCITT Fax, RLE, Flate, DCT) and ASCII85
+encoding is available. The package may be used for generating colour-
+separated EPSes, `EPS thumbnails,' and, moreover, little header EPSes,
+containing only a pointer to a source TIFF file. Employing Ghostscript
+guarantees portability and efficient processing.
+
+Batch files are provided: tif2eps.bat (for DOS/Windows) and tif2eps
+(for Unix/Linux). They should be copied to the directory in $PATH.
+The main `engine', tif2eps.ps should be copied to the directory with
+Ghostscript libraries, e.g.: /usr/local/share/ghostscript/<version>/lib/
+or C:\gstools\gs<version>\lib\
+
+Usage details:
+ gs [-dNODISPLAY] [-q] -- tif2eps.ps TIFF_name [EPS_name] [options]
+
+Options:
+ -f# -- output filtering, #=[compression][encoding], where
+ currently implemented compressions:
+ f - Flate, l - LZW, p - LZW with predictor, r - RLE,
+ 3 - CCITTFax group 3, 4 - CCITTFax group 4 (two-dimensional),
+ j - DCT (JPEG standard), n - none, or empty (default is n)
+ currently implemented encodings:
+ 8 - ASCII85, h - HEX, or empty (default is 8)
+ -d# -- override resolution (in dpi, X_RESxY_RES form allowed)
+ -o# -- overwrite output file: 0 - not (default), 1 - yes, 2 - if older
+ -l# -- Postscript Level of output EPS: 1 - Level 1, 2 - Level 2
+ -m# -- operator used for monochrome bitmaps: 0 - image (default),
+ 1 - imagemask, 2 - inversed imagemask
+ -p# -- convert # image (page) of multi-page TIFF (0 - first page)
+ -r# -- reduction (scaling) factor, 0<#<=1
+ -s# -- separation, #=1, 2, 3, 4, or c, m, y, k
+ -v# -- verbose level: 0 - off , 1 - basic (default), 2 - elaborate
+ -b* -- use exact (non-integer) BoundingBox comment format; otherwise
+ HiResBoundingBox is additionally written out (default is +)
+ -e* -- recover from errors (special RLE filter, CCITTFax recover)
+ -h* -- write `header' EPS (which reads and interpretes TIFF)
+ -i* -- set `/Interpolate' entry to true in EPS image
+ where asterisk denotes a switch:
+ on: + or 1 (or empty)
+ off: - or 0 (default if not specified otherwise)
+
diff --git a/support/pstools/tif2eps/readme.pol b/support/pstools/tif2eps/readme.pol
new file mode 100644
index 0000000000..0e85978572
--- /dev/null
+++ b/support/pstools/tif2eps/readme.pol
@@ -0,0 +1,57 @@
+TIF2EPS wer. 0.79, 1 marca 2005.
+
+Ten program jest wolnym oprogramowaniem; mo¿esz go rozprowadzaæ dalej
+i/lub modyfikowaæ na warunkach Powszechnej Licencji Publicznej GNU.
+Patrz: http://www.fsf.org/licenses/gpl.txt
+
+AUTORZY: Bogus³aw Jackowski, Piotr Pianowski, Piotr Strzelczyk
+Mail: BOP s.c., ul. Bora-Komorowskiego 24, 80-377 Gdañsk, Poland
+Email: P.Strzelczyk@GUST.org.pl, bop@bop.com.pl
+
+TIF2EPS jest PostScriptowym programem do konwersji grafiki z formatu TIFF
+(specyfikacja 6.0) na EPS. Pozwala na konwersjê z zastosowaniem kodowania
+ASCII85 i kompresji RLE, CCITT Fax, LZW, Flate i DCT (JPEG). Mo¿liwe
+jest generowanie rozbarwieñ, wgl±dówek (zmniejszanie rozdzielczo¶ci)
+oraz tworzenie plików EPS w formacie nag³ówkowym (malutki plik, wczytuj±cy
+zewnêtrzny plik TIFF i interpretuj±cy go). Dziêki wykorzystaniu
+Ghostscripta osi±gniêto przeno¶no¶æ oraz du¿± szybko¶æ pracy.
+
+Do pakietu za³±czono pliki uruchomieniowe: tif2eps.bat (dla DOS/Windows)
+i tif2eps (dla Unix/Linux). Powinny byæ one skopiowane do katalogu
+wskazywanego przez zmienn± $PATH. G³ówny program, tif2eps.ps, powinien
+byæ skopiowany do katalogu zawieraj±cego biblioteki Ghostscript, np.:
+/usr/local/share/ghostscript/<wersja>/lib/ albo C:\gstools\gs<wersja>\lib\
+
+Szczegó³y uruchamiania:
+ gs [-dNODISPLAY] [-q] -- tif2eps.ps plik_TIFF [plik_EPS] [opcje]
+
+Opcje:
+ -f# -- kodowanie wynikowe, #=[kompresja][kodowanie],
+ obecnie obs³ugiwane metody kompresji:
+ f - Flate, l - LZW, p - ZLW z predyktorem, r - RLE,
+ 3 - CCITTFax group 3, 4 - CCITTFax group 4 (dwuwymiarowy),
+ j - DCT (JPEG standard), n - brak (warto¶æ domy¶lna)
+ oraz nastêpuj±ce metody kodowania:
+ 8 - ASCII85, h - HEX (warto¶æ domy¶lna - 8)
+ -d# -- wymuszanie rozdzielczo¶ci (w dpi, dozwolona forma: X_RESxY_RES)
+ -o# -- nadpisywanie plików wynikowych: 0 - nie (domy¶lny), 1 - tak,
+ 2 - je¶li plik wynikowy jest starszy ni¿ plik ¼ród³owy
+ -l# -- wersja (Postscript Level) wynikowego EPS: 1 - Level 1, 2 - Level 2
+ -m# -- operator u¿ywany dla bitmap monochromatycznych:
+ 0 - image (domy¶lny), 1 - imagemask, 2 - odwrócona imagemask
+ -p# -- konwersja # strony obrazka dla wielostronicowego pliku TIFF
+ (0 - pierwsza strona)
+ -r# -- wspó³czynnik zmniejszenia (skalowania), 0<#<=1
+ -s# -- separacja, #=1, 2, 3, 4, or c, m, y, k
+ -v# -- poziom komunikatów: 0 - wy³±czony, 1 - podstawowy (domy¶lnie),
+ 2 - szczegó³owy
+ -b* -- u¿ycie precyzyjnego (nieca³kowitego) formatu komentarza
+ BoundingBox (domy¶lnie w³±czone), w przeciwnym razie
+ jest dopisywany komentarz HiResBoundingBox
+ -e* -- przetwarzanie niepoprawnych plików (specjalna dekompresja RLE
+ i CCITTFax, oraz korekcja d³ugo¶ci segmentów pliku ¼ród³owego)
+ -h* -- forma nag³ówkowa EPS-a (czyta zewnêtrzny plik TIFF)
+ -i* -- w³±czenie opcji ,,wyg³adzania'' obrazka (/Interpolate true)
+ w powy¿szych opcjach gwiazdka oznacza:
+ + lub 1 (lub brak znaku) -- w³±czenie opcji
+ - lub 0 -- wy³±czenie opcji \ No newline at end of file
diff --git a/support/pstools/tif2eps/tif2eps b/support/pstools/tif2eps/tif2eps
new file mode 100755
index 0000000000..642077142e
--- /dev/null
+++ b/support/pstools/tif2eps/tif2eps
@@ -0,0 +1,4 @@
+#!/bin/sh
+##Usage: tif2eps TIFF_name [EPS_name] [options]
+## tif2eps (without parameters) will display all options
+gs -dNODISPLAY -q -- tif2eps.ps "$@" \ No newline at end of file
diff --git a/support/pstools/tif2eps/tif2eps.bat b/support/pstools/tif2eps/tif2eps.bat
new file mode 100644
index 0000000000..79e87ffab1
--- /dev/null
+++ b/support/pstools/tif2eps/tif2eps.bat
@@ -0,0 +1,7 @@
+@ECHO OFF
+::Usage: tif2eps TIFF_name [EPS_name] [options]
+:: tif2eps (without parameters) will display all options
+::DOS (uncomment next line and comment out last one)
+REM gs386 -dNODISPLAY -q -- tif2eps.ps %1 %2 %3 %4 %5 %6 %7 %8 %9
+::Windows
+gswin32c -dNODISPLAY -q -- tif2eps.ps %1 %2 %3 %4 %5 %6 %7 %8 %9 \ No newline at end of file
diff --git a/support/pstools/tif2eps/tif2eps.ps b/support/pstools/tif2eps/tif2eps.ps
new file mode 100644
index 0000000000..a67e1539fc
--- /dev/null
+++ b/support/pstools/tif2eps/tif2eps.ps
@@ -0,0 +1,2246 @@
+%!
+% This is a PostScript program for making an EPS file from a TIFF
+%
+% Written in BOP s.c., Gda\'nsk, Poland
+% e-mail contact: P.Strzelczyk@GUST.ORG.PL
+%
+% This program is free software; you can redistribute it and/or
+% modify it under the terms of the GNU General Public License.
+% See: http://www.fsf.org/licenses/gpl.txt
+%
+% History:
+% version 0.30 (28 III 1998)
+%
+% version 0.35 (30 III 1998) Header EPSes added, a few buglets removed.
+%
+% version 0.40 (12-22 IV 1998) Fax-TIFF (CCITT Group III and IV) added,
+% more tags known, more efficient loops used,
+% separation in `header' EPSes supported
+% exact BoundingBox is now optional,
+% interpolation enabled, interpretation
+% of parameters improved, a heuristic
+% work-around applied for TIFFs without
+% specified resolution.
+%
+% version 0.50 (28 IV 1998) BachoTeX '98 release.
+%
+% version 0.55 (31 VII 1998) Verbose, imagemask and newer-overwrite
+% switches added, heuristic implicite
+% resolution calculation.
+% version 0.56 (13 VIII 1998) Bug in fixing output filter fixed;
+% some bugs introduced in ver. 0.55 fixed
+% better formatting of SBC and SOF tables.
+%
+% version 0.57 (25 VI 1999) Imagemask colouring enabled.
+%
+% version 0.58 (30 III 2000) Usage of ASCII85Encode filter adjusted
+% to Ghostscript 6.x (see ASCII85Encode).
+%
+% version 0.59 (10 IV 2000) `%%Creator:' DSC comment added.
+%
+% version 0.60 (4 V 2001) After `BachoTeX 2001' release:
+% - some minor bugs hunted, and probably many
+% new introduced ;(
+% - output filters added:
+% - LZW with horizontal predictor
+% - CCITTFax group 3
+% - CCITTFax group 4 (two-dimensional)
+% - DCT (JPEG standard)
+% - resolution can be forced from commandline
+% - location of image data not defined in TIFF
+% file is guessed (if it is possible)
+% - some errors in TIFFs are corrected:
+% - incompatible RLE is handled
+% - strips are checked to obtain correct length
+% - CCITTFax recover of next line is activated
+% - in header EPSes, a length of TIFF is
+% checked in order to avoid rendering
+% a wrong file with the same name
+% - predictor feature is moved to LZWDecode
+% parameter, where it was possible
+% This version is heavily rebuilded, and
+% intended to be tested intensively.
+%
+% version 0.61 (19 X 2001) Command `quit' added at the end of the script.
+%
+% version 0.62 (28 XI 2001) Processing of multipage TIFF files added
+% - option -p#, # - number of page to be
+% processed.
+%
+% version 0.63 (29 I 2002) Processing of very large (wide) TIFF images
+% implemented (many thanks to Howard Halstead),
+% slight code optimization, messages changed.
+%
+% version 0.64 (15 II 2002) Bugs in the processing of very wide TIFF
+% images fixed.
+%
+% version 0.65 (16 IV 2002) Checking of TIFF length disabled
+% (on Avantra RIP all files have length -1).
+%
+% version 0.66 (7 VI 2002) Generating of Level 1 EPSes.
+%
+% version 0.67 (25 X 2002) Work-around bug in reading short values
+% from IFD (stored as a long value,
+% procedure `convs').
+%
+% version 0.68 (7 XI 2002) A little but noxious bug in processing
+% of multipage TIFF files fixed.
+%
+% version 0.69 (30 XI 2002) `%%HiResBoundingBox:' comment added.
+%
+% version 0.70 (6 XII 2002) Licence changed to GPL, package name changed
+% from tiff2ps to tif2eps;
+% package submitted to SourceForge.net.
+%
+% version 0.71 (11 II 2003) At verbosity level 0, no messages are issued
+% (even error messages).
+%
+% version 0.72 (21 II 2003) Processing of 1- and 2-bit pallete images
+% added; do there exist 3-bit, 5-bit, 6-bit,
+% and 7-bit palletes? TIFF 6.0 specification
+% explicitly allows only 4- and 8-bit palletes.
+%
+% version 0.73 (5 IV 2003) Processing of zlib-compressed TIFFs
+% (compression type 8 and 32946) added,
+% zero and infinite resolutions are ignored
+% (72 dpi is assumed).
+%
+% version 0.74 (24 IV 2003) Usage message reenabled
+% (bug introduced in ver. 0.71).
+%
+% version 0.75 (13 V 2003) Processing of JPEG-compressed TIFFs
+% (compression type 7) added;
+% compression type 6 (TIFF native DCT;
+% obsolete?) still not supported.
+%
+% version 0.76 (11 VI 2004) One more bug in the processing of very
+% wide TIFF images fixed (in header form).
+%
+% version 0.77 (10 XII 2004) Patch for processing TIFFs LZW-packed
+% by a newer PhotoShop version (>4.x) --
+% discarding extra byte at the end of strip.
+%
+% version 0.78 (11 II 2005) Continuation of the previous fix:
+% corrected calculation of bytes per strip
+% in BW pictures.
+%
+% version 0.79 (1 III 2005) A bug in -o2 (overwrite if newer) option fixed:
+% the `created' field of the output file was
+% compared to the `referenced' field of the
+% input file. In Ghostscript, `referenced'
+% field means actually the modification time
+% (fortunately, although unorthodoxly),
+% so this field is now used for comparison.
+%
+% Usage:
+% gs [-dNODISPLAY] [-q] -- tif2eps.ps TIFF_name [EPS_name] [options]
+%
+% ---
+/edef {exch def} def
+/TIFFdictput {TIFFdict 3 1 roll exch put} def
+/printErr {EPSdict /Verbose get 0 gt {print}{pop} ifelse} def
+/printQuit {print (, quitting\n) print flush quit} def
+/flushclosefile {dup flushfile closefile} def
+/readb {infile read not {(Unexpected EOF, probably damaged TIFF file) printQuit} if} def
+/testandsetfileposition {
+ dup lengthofinfile gt {
+ (Unexpected EOF, probably damaged TIFF file) printQuit
+ } if
+ setfileposition
+} def
+/TIFFdict 255 dict def
+/IMAGEdict 255 dict def
+/EPSdict 255 dict def
+%---
+% Header of TIFF file
+/ReadHeader {
+ infile 0 setfileposition
+ readb dup 73 eq exch 77 eq % II or MM
+ readb dup 73 eq exch 77 eq %
+ 2 index and exch 3 index and
+ 4 2 roll pop pop
+ 2 copy or not
+ {(Not a TIFF file) printQuit} if
+ {% litle endian (II)
+ /reads {readb readb 256 mul add} def
+ /readl {readb readb readb readb 256 mul add 256 mul add 256 mul add} def
+ /convs {dup type (integertype) eq {655536 mod}
+ {dup 65536 div truncate 65536 mul sub cvi} ifelse} def % patch
+ /convIIs {dup type (integertype) eq {655536 idiv}
+ {65536 div cvi} ifelse} def % patch
+ } if
+ {% big endian (MM)
+ /reads {readb 256 mul readb add} def
+ /readl {readb 256 mul readb add 256 mul readb add 256 mul readb add} def
+ /convs {dup type (integertype) eq {65536 idiv}
+ {65536 div cvi} ifelse} def % patch
+ /convIIs {dup type (integertype) eq {65536 mod}
+ {dup 65536 div truncate 65536 mul sub cvi} ifelse} def % patch
+ } if
+ reads 42 ne % magic number
+ {(Not a TIFF file) printQuit} if
+ /IFDOffset readl def
+} def
+%---
+% Image File Directory (IFD)
+/ReadIFDs {
+ EPSdict /PageNumber known {
+ EPSdict /PageNumber get {
+ infile IFDOffset testandsetfileposition
+ reads % number of tags in IFD
+ 12 mul 2 add IFDOffset add
+ infile exch testandsetfileposition
+ readl dup 0 eq {% pointer to next IFD
+ (There are less pages in a TIFF file, then you speciefied) printQuit
+ } if
+ /IFDOffset edef
+ } repeat
+ } if
+ infile IFDOffset testandsetfileposition
+ reads % number of tags in IFD
+ {readtag} repeat
+ readl % pointer to next IFD
+ EPSdict /PageNumber known {pop}{
+ 0 eq not {
+ (More images in a TIFF file, the first one interpreted -- use -p option\n) printCon
+ } if
+ } ifelse
+ flush % show all previous messages
+} def
+%---
+% Interpreting TAGS
+/tmpstr 8 string def
+/readtag {
+ reads % TAG number
+ reads % field type
+ readl % field count
+ readl % offset to value or value
+ /returnfileposition infile fileposition def
+ 3 index dup tmpstr cvs cvn tagsdict exch known {
+ tmpstr cvs cvn tagsdict exch get
+ exec
+ }{
+ dup 32768 ge {
+ (Private tag \() printCon =string cvs printCon (\), ignored\n) printCon
+ }{
+ (Unknown tag ) printErr =string cvs printErr (, ignored\n) printErr
+ } ifelse
+ pop pop pop pop
+ } ifelse
+ infile returnfileposition setfileposition
+} def
+%---
+% Interpreting TAGS
+/PrepareTAGsDictionary {
+ % Additional definitions to analyze tags
+ /ascii {
+ 2 ne {(Bad tag type) printQuit} if
+ } def
+ /short {
+ 3 eq {convs}{(Bad tag type) printQuit} ifelse
+ } def
+ /long {
+ 4 ne {(Bad tag type) printQuit} if
+ } def
+ /rational {
+ 5 ne {(Bad tag type) printQuit} if
+ } def
+ /shortorlong {
+ dup 3 eq {
+ pop convs
+ }{
+ 4 ne {(Bad tag type) printQuit} if
+ } ifelse
+ } def
+ /toomany {
+ 1 ne {(Too many values for a tag) printQuit} if
+ } def
+ /interpreteascii {
+ pop % name of field
+ pop % value
+ pop % count
+ ascii
+ pop
+ } def
+ /interpreteshort {
+ pop % name of field
+ pop % value
+ pop % count
+ short
+ pop
+ } def
+ /knownnotinterpreted {
+ pop pop pop pop pop
+ } def
+ %---
+ % Definitions of TAGs
+ /tagsdict 255 dict def
+ tagsdict begin
+ /254 {
+ exch toomany
+ exch long
+ exch pop
+ dup 0 eq exch 2 eq or not
+ {(Not the main image -- weird output expected\n) printErr} if
+ } def
+ /255 {
+ exch toomany
+ exch short
+ exch pop
+ dup 1 eq exch 3 eq or not
+ {(Not the main image -- weird output expected\n) printErr} if
+ } def
+ /256 {
+ exch toomany
+ exch shortorlong
+ exch pop
+ /Width TIFFdictput
+ } def
+ /257 {
+ exch toomany
+ exch shortorlong
+ exch pop
+ /Length TIFFdictput
+ } def
+ /258 {
+ exch /NOV edef TIFFdict /SamplesPerPixelX NOV put
+ exch 3 ne {(Bad tag type) printQuit} if % modified short
+ exch pop
+ NOV 1 eq {
+ convs /BitsPerSample TIFFdictput
+ } if
+ NOV 2 eq {
+ dup dup convs exch convIIs eq {
+ convs /BitsPerSample TIFFdictput
+ }{
+ pop (Samples have not equal numbers of bits, can't process image) printQuit
+ } ifelse
+ } if
+ NOV 2 gt {
+ infile exch testandsetfileposition
+ NOV {reads} repeat
+ true NOV 1 sub {exch 2 index eq and} repeat
+ {
+ /BitsPerSample TIFFdictput
+ }{
+ pop (Samples have not equal numbers of bits, can't process image) printQuit
+ } ifelse
+ } if
+ } def
+ /259 {
+ exch toomany
+ exch short
+ exch pop
+ /Compression TIFFdictput
+ } def
+ /262 {
+ exch toomany
+ exch short
+ exch pop
+ /PhotometricInterpretation TIFFdictput
+ } def
+ /263 {
+ (Tresholding) interpreteshort
+ } def
+ /264 {
+ (CellWidth) knownnotinterpreted
+ } def
+ /265 {
+ (CellHeight) knownnotinterpreted
+ } def
+ /266 {
+ exch toomany
+ exch short
+ exch pop
+ /FillOrder TIFFdictput
+ } def
+ /269 {
+ (DocumentName) interpreteascii
+ } def
+ /270 {
+ (ImageDescription) interpreteascii
+ } def
+ /271 {
+ (Make) interpreteascii
+ } def
+ /272 {
+ (Model) interpreteascii
+ } def
+ /273 {
+ exch /NOV edef TIFFdict /StripsPerImageX NOV put
+ exch /LOV edef LOV 3 ne LOV 4 ne and {(Bad tag type) printQuit} if % modified shortlong
+ exch pop
+ /TOV NOV array def
+ LOV 3 eq {
+ NOV 1 eq {convs TOV 0 2 index put pop} if
+ NOV 2 eq {
+ dup convs TOV 0 2 index put pop
+ convIIs TOV 1 2 index put pop
+ } if
+ NOV 2 gt {
+ infile exch testandsetfileposition
+ 0 NOV {dup 1 add exch TOV exch reads put} repeat pop
+ } if
+ }{
+ NOV 1 eq {TOV 0 2 index put pop} if
+ NOV 1 gt {
+ infile exch testandsetfileposition
+ 0 NOV {dup 1 add exch TOV exch readl put} repeat pop
+ } if
+ } ifelse
+ TIFFdict /StripOffsets TOV put
+ } def
+ /274 {
+ exch toomany
+ exch short
+ exch pop
+ /Orientation TIFFdictput
+ } def
+ /277 {
+ exch toomany
+ exch short
+ exch pop
+ /SamplesPerPixel TIFFdictput
+ } def
+ /278 {
+ exch toomany
+ exch shortorlong
+ exch pop
+ /RowsPerStrip TIFFdictput
+ } def
+ /279 {
+ exch /NOV edef TIFFdict /StripsPerImageY NOV put
+ exch /LOV edef LOV 3 ne LOV 4 ne and {(Bad tag type) printQuit} if % modified shortlong
+ exch pop
+ /TOV NOV array def
+ LOV 3 eq {
+ NOV 1 eq {convs TOV 0 2 index put pop} if
+ NOV 2 eq {
+ dup convs TOV 0 2 index put pop
+ convIIs TOV 1 2 index put pop
+ } if
+ NOV 2 gt {
+ infile exch testandsetfileposition
+ 0 NOV {dup 1 add exch TOV exch reads put} repeat pop
+ } if
+ }{
+ NOV 1 eq {TOV 0 2 index put pop} if
+ NOV 1 gt {
+ infile exch testandsetfileposition
+ 0 NOV {dup 1 add exch TOV exch readl put} repeat pop
+ } if
+ } ifelse
+ TIFFdict /StripByteCounts TOV put
+ } def
+ /280 {
+ (MinSampleValue) interpreteshort
+ } def
+ /281 {
+ (MaxSampleValue) interpreteshort
+ } def
+ /282 {
+ exch toomany
+ exch rational
+ exch pop
+ infile exch testandsetfileposition
+ TIFFdict /XResolution readl readl
+ dup 0 eq {
+ (Bad resolution -- divide by zero, changed to 1.\n) printErr
+ pop 1} if
+ div put
+ } def
+ /283 {
+ exch toomany
+ exch rational
+ exch pop
+ infile exch testandsetfileposition
+ TIFFdict /YResolution readl readl
+ dup 0 eq {
+ (Bad resolution -- divide by zero, changed to 1.\n) printErr
+ pop 1} if
+ div put
+ } def
+ /284 {
+ exch toomany
+ exch short
+ exch pop
+ /PlanarConfiguration TIFFdictput
+ } def
+ /285 {
+ (PageName) interpreteascii
+ } def
+ /286 {
+ (XPosition) knownnotinterpreted
+ } def
+ /287 {
+ (YPosition) knownnotinterpreted
+ } def
+ /288 {
+ (FreeOffsets) knownnotinterpreted
+ } def
+ /289 {
+ (FreeByteCounts) knownnotinterpreted
+ } def
+ /290 {
+ (GrayResponseUnit) knownnotinterpreted
+ } def
+ /291 {
+ (GrayResponseCurve) knownnotinterpreted
+ } def
+ /292 {
+ exch toomany
+ exch long
+ exch pop
+ /T4Options TIFFdictput
+ } def
+ /293 {
+ exch toomany
+ exch long
+ exch pop
+ /T6Options TIFFdictput
+ } def
+ /296 {
+ exch toomany
+ exch short
+ exch pop
+ /ResolutionUnit TIFFdictput
+ } def
+ /297 {
+ exch 2 ne {(Bad number of values for a tag) printQuit} if % modified toomany
+ exch 3 ne {(Bad tag type) printQuit} if % modified short
+ exch pop
+ dup convs /PageNumber TIFFdictput
+ convIIs /NumberOfPages TIFFdictput
+ } def
+ /301 {
+ (TransferFunction) knownnotinterpreted
+ } def
+ /305 {
+ (Software) interpreteascii
+ } def
+ /306 {
+ (DateTime) interpreteascii
+ } def
+ /315 {
+ (Artist) interpreteascii
+ } def
+ /316 {
+ (HostComputer) interpreteascii
+ } def
+ /317 {
+ exch toomany
+ exch short
+ exch pop
+ /Predictor TIFFdictput
+ } def
+ /320 {
+ exch /NOV edef
+ NOV 6 eq dup {1 /BitsPerSampleX TIFFdictput} if
+ NOV 12 eq dup {2 /BitsPerSampleX TIFFdictput} if
+ NOV 48 eq dup {4 /BitsPerSampleX TIFFdictput} if
+ NOV 768 eq dup {8 /BitsPerSampleX TIFFdictput} if
+ or or or not {(Weird pallete mode) printQuit} if
+ exch 3 ne {(Bad tag type) printQuit} if % modified short
+ exch pop
+ /TOV NOV string def
+ infile exch testandsetfileposition
+ 0 NOV {dup 1 add exch TOV exch reads 256 idiv put} repeat pop
+ TIFFdict /ColorMap TOV put
+ } def
+ /322 {
+ exch toomany
+ exch shortorlong
+ exch pop
+ /TileWidth TIFFdictput
+ } def
+ /323 {
+ exch toomany
+ exch shortorlong
+ exch pop
+ /TileHeight TIFFdictput
+ } def
+ /324 {
+ exch /NOV edef TIFFdict /TilesPerImageX NOV put
+ exch long
+ exch pop
+ /TOV NOV array def
+ % always long data
+ NOV 1 eq {TOV 0 2 index put pop} if
+ NOV 1 gt {
+ infile exch testandsetfileposition
+ 0 NOV {dup 1 add exch TOV exch readl put} repeat pop
+ } if
+ TIFFdict /TileOffsets TOV put
+ } def
+ /325 {
+ exch /NOV edef TIFFdict /TilesPerImageY NOV put
+ exch /LOV edef LOV 3 ne LOV 4 ne and {(Bad tag type) printQuit} if % modified shortlong
+ exch pop
+ /TOV NOV array def
+ LOV 3 eq {
+ NOV 1 eq {convs TOV 0 2 index put pop} if
+ NOV 2 eq {
+ dup convs TOV 0 2 index put pop
+ convIIs TOV 1 2 index put pop
+ } if
+ NOV 2 gt {
+ infile exch testandsetfileposition
+ 0 NOV {dup 1 add exch TOV exch reads put} repeat pop
+ } if
+ }{
+ NOV 1 eq {TOV 0 2 index put pop} if
+ NOV 1 gt {
+ infile exch testandsetfileposition
+ 0 NOV {dup 1 add exch TOV exch readl put} repeat pop
+ } if
+ } ifelse
+ TIFFdict /TileByteCounts TOV put
+ } def
+ /327 {
+ (CleanFaxData) interpreteshort
+ } def
+ /332 {
+ exch toomany
+ exch short
+ exch pop
+ /InkSet TIFFdictput
+ } def
+ /334 {
+ exch toomany
+ exch short
+ exch pop
+ /SamplesPerPixelY TIFFdictput
+ } def
+ /336 {
+ (DotRange) knownnotinterpreted
+ } def
+ /337 {
+ (TargetPrinter) interpreteascii
+ } def
+ /338 {
+ exch /ExtraSamples TIFFdictput
+ exch short
+ exch pop
+ pop
+ } def
+ /347 {
+ /JPEGTableOffset TIFFdictput
+ /JPEGTableLength TIFFdictput
+ 7 ne {(Bad tag type) printQuit} if % Type = UNDEFINED
+ pop
+ } def
+ /33432 {
+ (Copyright) interpreteascii
+ } def
+ /34377 {
+ (PhotoShop private field) knownnotinterpreted
+ } def
+ end
+} def
+%---
+/ProcessImageDict {
+ %
+ % required:
+ % /Width
+ % /Length
+ % /PhotometricInterpretation
+ % /XResolution
+ % /YResolution
+ % /Compression
+ % /RowsPerStrip
+ % /StripByteCounts
+ % /StripOffsets
+ %
+ % other used by program:
+ % /ResolutionUnit
+ % /BitsPerSample
+ % /SamplesPerPixel
+ % /ExtraSamples
+ % /ColorMap
+ % /FillOrder
+ % /Predictor
+ % /Orientation
+ % /PlanarConfiguration
+ % /InkSet
+ % /T4Options
+ % /T6Options
+ % /PageNumber
+ % /NumberOfPages
+ % /TileWidth
+ % /TileHeight
+ % /TileByteCounts
+ % /TileOffsets
+ % /JPEGTableOffset
+ % /JPEGTableLength
+ %
+ % calculated from others:
+ % /BitsPerSampleX
+ % /SamplesPerPixelX
+ % /SamplesPerPixelY
+ % /StripsPerImageX
+ % /StripsPerImageY
+ % /TilesPerImageX
+ % /TilesPerImageY
+
+ IMAGEdict /ImageType 1 put
+
+ TIFFdict /Width known {
+ IMAGEdict /Width TIFFdict /Width get put
+ }{
+ (Bitmap width not given) printQuit
+ } ifelse
+
+ TIFFdict /Length known {
+ IMAGEdict /Height TIFFdict /Length get put
+ }{
+ (Bitmap height not given) printQuit
+ } ifelse
+
+ TIFFdict /PhotometricInterpretation known not {
+ (Photometric interpretation not given) printQuit
+ } if
+
+ TIFFdict /PhotometricInterpretation get 1 le {
+ IMAGEdict /ColorSpace [/DeviceGray] put
+ TIFFdict /SamplesPerPixel known not {TIFFdict /SamplesPerPixel 1 put} if
+ IMAGEdict /ExpectedSamplesPerPixel 1 put
+ TIFFdict /BitsPerSample known not {TIFFdict /BitsPerSample 1 put} if
+ TIFFdict /PhotometricInterpretation get
+ 0 eq {IMAGEdict /Decode [1 0] put}{IMAGEdict /Decode [0 1] put} ifelse
+ } if
+
+ TIFFdict /PhotometricInterpretation get 2 eq {
+ IMAGEdict /ColorSpace [/DeviceRGB] put
+ IMAGEdict /ExpectedSamplesPerPixel 3 put
+ IMAGEdict /Decode [0 1 0 1 0 1] put
+ } if
+
+ TIFFdict /PhotometricInterpretation get 3 eq {
+ TIFFdict /BitsPerSample known {
+ /ihival 1 TIFFdict /BitsPerSample get bitshift def
+ }{
+ (Number of colors unknown) printQuit
+ } ifelse
+ TIFFdict /ColorMap known {
+ /icm TIFFdict /ColorMap get def
+ icm length 3 div ihival ne {(Bad palette size) printQuit} if
+ /ocm icm length string def
+ 0 1 ihival 1 sub {% interleaving the palette
+ dup icm exch get ocm exch 2 index 3 mul exch put
+ dup ihival add icm exch get ocm exch 2 index 3 mul 1 add exch put
+ dup ihival dup add add icm exch get ocm exch 2 index 3 mul 2 add exch put
+ pop
+ } for
+ TIFFdict /ColorMap ocm put
+ }{
+ (Palette not given) printQuit
+ } ifelse
+ TIFFdict /SamplesPerPixel known not {TIFFdict /SamplesPerPixel 1 put} if
+ IMAGEdict /HiVal ihival 1 sub put
+ IMAGEdict /ExpectedSamplesPerPixel 1 put
+ IMAGEdict /ColorSpace [/Indexed
+ /DeviceRGB IMAGEdict /HiVal get TIFFdict /ColorMap get] put
+ IMAGEdict /Decode [0 IMAGEdict /HiVal get] put
+ } if
+
+ TIFFdict /PhotometricInterpretation get 5 eq {
+ TIFFdict /InkSet known {
+ TIFFdict /InkSet get 1 ne {(Not CMYK separations -- mode not supported) printQuit} if
+ } if
+ IMAGEdict /ExpectedSamplesPerPixel 4 put
+ IMAGEdict /ColorSpace [/DeviceCMYK] put
+ IMAGEdict /Decode [0 1 0 1 0 1 0 1] put
+ } if
+
+ TIFFdict /PhotometricInterpretation get 6 eq
+ TIFFdict /Compression get 7 eq and {
+ IMAGEdict /ColorSpace [/DeviceRGB] put
+ IMAGEdict /ExpectedSamplesPerPixel 3 put
+ IMAGEdict /Decode [0 1 0 1 0 1] put
+ } if
+
+ % none of known PhotometricInterpretation was recognized
+ IMAGEdict /ExpectedSamplesPerPixel known not {
+ (Photometric interpretation unknown) printQuit
+ } if
+
+ TIFFdict /SamplesPerPixel known {
+ IMAGEdict /SamplesPerPixel TIFFdict /SamplesPerPixel get put
+ TIFFdict /SamplesPerPixel get IMAGEdict /ExpectedSamplesPerPixel get sub
+ dup 0 gt {
+ IMAGEdict /ExtraSamplesX 2 index put pop
+ }{
+ 0 lt {(Insufficient number of samples per pixel) printQuit} if
+ } ifelse
+ }{
+ (Number of samples per pixel not given) printQuit
+ } ifelse
+
+ TIFFdict /SamplesPerPixelX known {
+ TIFFdict /SamplesPerPixel get TIFFdict /SamplesPerPixelX get ne
+ {%should be
+ % (Inconsistent number of samples per pixel) printQuit
+ % but I encountered a readable file with inconsisntent
+ % number of samples, ie., extra samples are not counted
+ % in BitsPerSample
+ (Inconsistent number of samples per pixel\n) printErr
+ } if
+ } if
+
+ TIFFdict /SamplesPerPixelY known {
+ TIFFdict /SamplesPerPixel get TIFFdict /SamplesPerPixelY get ne
+ {(Inconsistent number of samples per pixel) printQuit} if
+ } if
+
+ TIFFdict /BitsPerSample known {
+ IMAGEdict /BitsPerComponent TIFFdict /BitsPerSample get put
+ }{
+ (Number of bits per sample not given) printQuit
+ } ifelse
+
+ TIFFdict /BitsPerSampleX known {
+ TIFFdict /BitsPerSample get TIFFdict /BitsPerSampleX get ne
+ {(Inconsistent number of bits per sample) printQuit} if
+ } if
+
+ TIFFdict /Orientation known not {TIFFdict /Orientation 1 put} if
+ TIFFdict begin Orientation
+ dup 1 eq {IMAGEdict /ImageMatrix [Width 0 0 Length neg 0 Length] put} if
+ dup 2 eq {IMAGEdict /ImageMatrix [Width neg 0 0 Length neg Width Length] put} if
+ dup 3 eq {IMAGEdict /ImageMatrix [Width neg 0 0 Length Width 0] put} if
+ dup 4 eq {IMAGEdict /ImageMatrix [Width 0 0 Length 0 0] put} if
+ dup 5 eq {IMAGEdict /ImageMatrix [0 Width neg Length 0 Width] put} if
+ dup 6 eq {IMAGEdict /ImageMatrix [0 Width neg Length neg 0 Length Width] put} if
+ dup 7 eq {IMAGEdict /ImageMatrix [0 Width Length neg 0 Length 0] put} if
+ dup 8 eq {IMAGEdict /ImageMatrix [0 Width Length 0 0 0] put} if
+ 8 gt {(Strange orientation) printQuit} if
+ end
+
+ EPSdict /XResolution known {
+ (TIFF resolution overridden\n) printCon
+ TIFFdict /XResolution EPSdict /XResolution get put
+ TIFFdict /YResolution EPSdict /YResolution get put
+ TIFFdict /ResolutionUnit 2 put
+ } if
+
+ TIFFdict /ResolutionUnit known {
+ TIFFdict /ResolutionUnit get 3 gt
+ {(Bad `ResolutionUnit' value) printQuit} if
+ }{
+ TIFFdict /ResolutionUnit 2 put % default according to specifications is dpi
+ } ifelse
+
+ TIFFdict /XResolution known
+ TIFFdict /YResolution known or not {
+ (Resolution not given -- assuming 72 dpi\n) printCon
+ TIFFdict /XResolution 72 put
+ TIFFdict /YResolution 72 put
+ } if
+
+ % there one of resolution value must be known
+ TIFFdict /XResolution known not {
+ (XResolution not given -- assuming square pixels\n) printCon
+ TIFFdict /XResolution TIFFdict /YResolution get put
+ } if
+ TIFFdict /YResolution known not {
+ (YResolution not given -- assuming square pixels\n) printCon
+ TIFFdict /YResolution TIFFdict /XResolution get put
+ } if
+
+ TIFFdict /XResolution get 0.01 le dup {
+ TIFFdict /XResolution 72 put
+ } if
+ TIFFdict /YResolution get 0.01 le dup {
+ TIFFdict /YResolution 72 put
+ } if
+ or {
+ (Zero resolution given -- assuming 72 dpi\n) printCon
+ } if
+
+ TIFFdict begin
+ ResolutionUnit 1 eq {
+ Width % assuming physical XResolution 72 ppi
+ Length YResolution XResolution div div
+ } if
+ ResolutionUnit 2 eq {
+ Width XResolution div 72 mul
+ Length YResolution div 72 mul
+ } if
+ ResolutionUnit 3 eq {
+ Width XResolution div 2.54 div 72 mul
+ Length YResolution div 2.54 div 72 mul
+ } if
+ Orientation 4 gt {exch} if
+ IMAGEdict /YScale 2 index put pop IMAGEdict /XScale 2 index put pop
+ end
+
+ TIFFdict /RowsPerStrip known {
+ IMAGEdict /StripsPerImage TIFFdict /Length get TIFFdict /RowsPerStrip get
+ div ceiling cvi put
+ }{
+ TIFFdict /RowsPerStrip TIFFdict /Length get put
+ IMAGEdict /StripsPerImage 1 put
+ } ifelse
+
+ TIFFdict /StripsPerImageX known {
+ IMAGEdict /StripsPerImage get TIFFdict /StripsPerImageX get ne
+ {(Inconsistent number of strips per image) printQuit} if
+ } if
+
+ TIFFdict /StripsPerImageY known {
+ IMAGEdict /StripsPerImage get TIFFdict /StripsPerImageY get ne
+ {(Inconsistent number of strips per image) printQuit} if
+ } if
+
+ TIFFdict /Compression known {
+ TIFFdict /Compression get
+ dup 2 eq {
+ IMAGEdict /Decompression {<</EncodedByteAlign true /BlackIs1 true /Columns WOI>> /CCITTFaxDecode filter} put
+ IMAGEdict /DecompressionString ( <</EncodedByteAlign true /BlackIs1 true /Columns OWOI>> /CCITTFaxDecode filter\n) put
+ } if
+ dup 3 eq {
+ IMAGEdict /Decompression {<</BlackIs1 true /Columns WOI>> /CCITTFaxDecode filter} put
+ IMAGEdict /DecompressionString ( <</BlackIs1 true /Columns OWOI>> /CCITTFaxDecode filter\n) put
+ } if
+ dup 4 eq {
+ IMAGEdict /Decompression {<</K -1 /BlackIs1 true /Columns WOI>> /CCITTFaxDecode filter} put
+ IMAGEdict /DecompressionString ( <</K -1 /BlackIs1 true /Columns OWOI>> /CCITTFaxDecode filter\n) put
+ } if
+ dup 5 eq {
+ IMAGEdict /Decompression {/LZWDecode filter LOS () /SubFileDecode filter} put
+ IMAGEdict /DecompressionString ( /LZWDecode filter LOS () /SubFileDecode filter\n) put
+ } if
+ dup 7 eq {
+ IMAGEdict /Decompression {/DCTDecode filter} put
+ IMAGEdict /DecompressionString ( /DCTDecode filter\n) put
+ TIFFdict /PhotometricInterpretation get 2 eq {
+ IMAGEdict /Decompression {<</ColorTransform 0>> /DCTDecode filter} put
+ IMAGEdict /DecompressionString ( <</ColorTransform 0>> /DCTDecode filter\n) put
+ } if
+ } if
+ dup 8 eq 1 index 32946 eq or {
+ IMAGEdict /Decompression {/FlateDecode filter} put
+ IMAGEdict /DecompressionString ( /FlateDecode filter\n) put
+ } if
+ dup 32773 eq {
+ IMAGEdict /Decompression {/RunLengthDecode filter} put
+ IMAGEdict /DecompressionString ( /RunLengthDecode filter\n) put
+ } if
+ 1 ne IMAGEdict /Decompression known not and {
+ (Unknown compression method) printQuit
+ } if
+ }{
+ (Compression method not given) printQuit
+ } ifelse
+
+ TIFFdict /T4Options known {
+ TIFFdict /Compression get 3 eq {
+ TIFFdict /T4Options get
+ 5 and % we takes care of 0 and 2 bit (bit 1 is not needed)
+ % 0 eq is prepared in Compression section
+ dup 1 eq {
+ IMAGEdict /Decompression {<</K 1 /BlackIs1 true /Columns WOI>> /CCITTFaxDecode filter} put
+ IMAGEdict /DecompressionString ( <</K 1 /BlackIs1 true /Columns OWOI>> /CCITTFaxDecode filter\n) put
+ } if
+ dup 4 eq {
+ % I don't know what second bit means. I thought that it is
+ % equivalent to: `/EncodedByteAlign true' but it isn't true!
+ IMAGEdict /Decompression {<</BlackIs1 true /Columns WOI>> /CCITTFaxDecode filter} put
+ IMAGEdict /DecompressionString ( <</BlackIs1 true /Columns OWOI>> /CCITTFaxDecode filter\n) put
+ } if
+ 5 eq {
+ IMAGEdict /Decompression {<</K 1 /BlackIs1 true /Columns WOI>> /CCITTFaxDecode filter} put
+ IMAGEdict /DecompressionString ( <</K 1 /BlackIs1 true /Columns OWOI>> /CCITTFaxDecode filter\n) put
+ } if
+ }{
+ % probably should be `printQuit', but Ghostscript generetes TIFF with
+ % this tag and Modified Huffman run length encoding (compression=2)
+ (T4Options given for compression other than CCITT T.4, ignoring\n) printErr
+ } ifelse
+ } if
+
+ TIFFdict /T6Options known {
+ TIFFdict /Compression get 4 eq {
+ % bit 0 -- unused
+ % bit 1 -- uncompressed mode is always allowed in PostScript
+ }{
+ (T6Options given for compression other than CCITT T.6, ignoring\n) printErr
+ } ifelse
+ } if
+
+ TIFFdict /JPEGTableOffset known {
+ TIFFdict /Compression get 7 eq {
+ IMAGEdict /DCTProc {
+ /DCTTMPfile exch def /DCTfirsttime true def
+ {DCTfirsttime {
+ /DCTfirsttime false def DCTTable
+ }{
+ DCTTMPfile DCTTMPstr readstring pop
+ } ifelse
+ }
+ } put
+ }{
+ (JPEGTable given for compression other than 7 (JPEG), ignoring\n) printErr
+ } ifelse
+ } if
+
+ EPSdict /Recover get {
+ TIFFdict /Compression get
+ dup 2 eq {
+ IMAGEdict /Decompression {<</EncodedByteAlign true /BlackIs1 true /Columns WOI /DamagedRowsBeforeError 10 >> /CCITTFaxDecode filter} put
+ IMAGEdict /DecompressionString ( <</EncodedByteAlign true /BlackIs1 true /Columns OWOI /DamagedRowsBeforeError 10 >> /CCITTFaxDecode filter\n) put
+ } if
+ dup 3 eq {
+ IMAGEdict /Decompression {<</BlackIs1 true /Columns WOI /DamagedRowsBeforeError 10 >> /CCITTFaxDecode filter} put
+ IMAGEdict /DecompressionString ( <</BlackIs1 true /Columns OWOI /DamagedRowsBeforeError 10 >> /CCITTFaxDecode filter\n) put
+ TIFFdict /T4Options known {
+ TIFFdict /T4Options get 1 and % we takes care only of 0 bit
+ 1 eq {
+ IMAGEdict /Decompression {<</K 1 /BlackIs1 true /Columns WOI /DamagedRowsBeforeError 10 >> /CCITTFaxDecode filter} put
+ IMAGEdict /DecompressionString ( <</K 1 /BlackIs1 true /Columns OWOI /DamagedRowsBeforeError 10 >> /CCITTFaxDecode filter\n) put
+ } if
+ } if
+ } if
+ dup 4 eq {
+ IMAGEdict /Decompression {<</K -1 /BlackIs1 true /Columns WOI /DamagedRowsBeforeError 10 >> /CCITTFaxDecode filter} put
+ IMAGEdict /DecompressionString ( <</K -1 /BlackIs1 true /Columns OWOI /DamagedRowsBeforeError 10 >> /CCITTFaxDecode filter\n) put
+ } if
+ dup 32773 eq {
+ IMAGEdict /Decompression {MyRunLengthDecode} put
+ IMAGEdict /DecompressionString ( MyRunLengthDecode\n) put
+ } if
+ } if
+
+ TIFFdict /FillOrder known {
+ TIFFdict /FillOrder get
+ dup 2 eq {
+ IMAGEdict /FillOrderProc {
+ /InFillOrderFile edef
+ /FillOrderTmpString 255 string def
+ <008040c020a060e0109050d030b070f0088848c828a868e8189858d838b878f8
+ 048444c424a464e4149454d434b474f40c8c4ccc2cac6cec1c9c5cdc3cbc7cfc
+ 028242c222a262e2129252d232b272f20a8a4aca2aaa6aea1a9a5ada3aba7afa
+ 068646c626a666e6169656d636b676f60e8e4ece2eae6eee1e9e5ede3ebe7efe
+ 018141c121a161e1119151d131b171f1098949c929a969e9199959d939b979f9
+ 058545c525a565e5159555d535b575f50d8d4dcd2dad6ded1d9d5ddd3dbd7dfd
+ 038343c323a363e3139353d333b373f30b8b4bcb2bab6beb1b9b5bdb3bbb7bfb
+ 078747c727a767e7179757d737b777f70f8f4fcf2faf6fef1f9f5fdf3fbf7fff>
+ /binv exch def
+ {
+ InFillOrderFile FillOrderTmpString readstring pop
+ dup length 1 sub 0 exch 1 exch {
+ FillOrderTmpString exch binv FillOrderTmpString 2 index
+ get get put
+ } for
+ } 0 () /SubFileDecode filter
+ } put
+ } if
+ 1 ne IMAGEdict /FillOrderProc known not and {
+ (Unknown FillOrder value) printQuit
+ } if
+ } if
+
+ EPSdict /Recover get {
+ IMAGEdict /CheckStripProc {
+ /InCheckStripFile edef
+ /CheckStripTmpString WOI SPL idiv NOC mul BPS mul 8 div ceiling cvi string def
+ /CheckStripBytes LOS RPS idiv
+ ACTS NOS 1 sub eq {HOI RPS ACTS mul sub}{RPS} ifelse mul def
+ {
+ InCheckStripFile CheckStripTmpString readstring pop
+ dup length dup CheckStripBytes gt {
+ (Recover applied -- some extra bytes was discarded\n) printErr
+ pop 0 CheckStripBytes getinterval
+ }{
+ 0 eq CheckStripBytes 0 gt and {
+ (Recover applied -- some missing bytes added\n) printErr
+ pop CheckStripTmpString dup length CheckStripBytes gt {
+ 0 CheckStripBytes getinterval
+ } if
+ } if
+ } ifelse
+ /CheckStripBytes CheckStripBytes 2 index length sub def
+ } 0 () /SubFileDecode filter
+ } put
+ } if
+
+ TIFFdict /Predictor known {
+ TIFFdict /Predictor get
+ dup 2 eq {pop
+ TIFFdict /Compression get
+ dup 5 eq {
+ IMAGEdict /Decompression {<</Predictor 2 /Columns WOI /Colors NOC /BitsPerComponent BPS>> /LZWDecode filter LOS () /SubFileDecode filter} put
+ IMAGEdict /DecompressionString ( <</Predictor 2 /Columns OWOI /Colors NOC /BitsPerComponent BPS>> /LZWDecode filter LOS () /SubFileDecode filter\n) put
+ } if
+ dup 8 eq 1 index 32946 eq or {
+ IMAGEdict /Decompression {<</Predictor 2 /Columns WOI /Colors NOC /BitsPerComponent BPS>> /FlateDecode filter} put
+ IMAGEdict /DecompressionString ( <</Predictor 2 /Columns OWOI /Colors NOC /BitsPerComponent BPS>> /FlateDecode filter\n) put
+ } if
+ dup 5 ne exch dup 8 ne exch 32946 ne and and {
+ IMAGEdict /PredictorProc {
+ /InPredictorFile edef
+ /PredictorTmpString WOI SPL idiv NOC mul string def
+ {
+ /LastPix [ NOC {0} repeat ] def /PredictorCount 0 def
+ InPredictorFile PredictorTmpString readstring pop
+ dup {
+ LastPix PredictorCount NOC mod get add 256 mod dup
+ LastPix exch PredictorCount NOC mod exch put
+ PredictorTmpString PredictorCount 2 index put pop
+ /PredictorCount PredictorCount 1 add def
+ } forall
+ } 0 () /SubFileDecode filter
+ } put
+ } if
+ }{
+ 1 ne {(Unknown predictor coding) printQuit} if
+ } ifelse
+ } if
+
+ TIFFdict /ExtraSamples known {
+ TIFFdict /ExtraSamples get 0 gt {
+ IMAGEdict /ExtraSamplesX known {
+ TIFFdict /ExtraSamples get IMAGEdict /ExtraSamplesX get
+ ne {(Inconsistent number of extra samples) printQuit} if
+ }{
+ (Inconsistent number of extra samples) printQuit
+ } ifelse
+ IMAGEdict /ExtraSamples TIFFdict /ExtraSamples get put
+ IMAGEdict /ExtraSamplesProc {
+ /InExtraSamplesFile edef
+ /NRS NOC IMAGEdict /ExtraSamples get sub def /ONRS NRS def
+ /IExtraSamplesString WOI SPL idiv NOC mul string def
+ /OExtraSamplesString WOI SPL idiv NRS mul string def
+ {
+ /IExtraSamplesCount 0 def /OExtraSamplesCount 0 def
+ InExtraSamplesFile IExtraSamplesString readstring pop
+ length NOC idiv {
+ OExtraSamplesString OExtraSamplesCount
+ IExtraSamplesString IExtraSamplesCount NRS getinterval
+ putinterval
+ /OExtraSamplesCount OExtraSamplesCount NRS add def
+ /IExtraSamplesCount IExtraSamplesCount NOC add def
+ } repeat
+ OExtraSamplesString
+ } 0 () /SubFileDecode filter
+ } put
+ } if
+ }{
+ IMAGEdict /ExtraSamplesX known
+ {(Inconsistent number of extra samples) printQuit} if
+ } ifelse
+
+ TIFFdict /TileWidth known
+ TIFFdict /TileHeight known
+ TIFFdict /TileOffsets known
+ TIFFdict /TileByteCounts known
+ 4 copy and and and {
+ (Can't process tiled image \(yet\)) printQuit
+ } if
+ or or or {
+ (Can't process tiled image, especially malformed) printQuit
+ } if
+
+ TIFFdict /StripOffsets known not {
+ IMAGEdict /StripsPerImage get 1 eq {
+ (Image location not given -- assume that image begins right after header\n) printErr
+ TIFFdict /StripOffsets [ returnfileposition ] put
+ }{
+ (Image location not given) printQuit
+ } ifelse
+ } if
+
+ TIFFdict /StripByteCounts known not {
+ IMAGEdict /StripsPerImage get 1 eq {
+ (Image size not given -- will be guessed\n) printErr
+ TIFFdict /Compression get 1 eq {
+ TIFFdict /StripByteCounts [ IMAGEdict /Width get
+ IMAGEdict /SamplesPerPixel get mul
+ IMAGEdict /BitsPerComponent get mul 8 div ceiling cvi
+ IMAGEdict /Height get mul ] put
+ }{
+ TIFFdict /StripByteCounts [ lengthofinfile
+ TIFFdict /StripOffsets get 0 get sub ] put
+ } ifelse
+ }{
+ (Image size not given -- can be guessed, but I newer seen such TIFF) printQuit
+ } ifelse
+ } if
+
+ 0 1 IMAGEdict /StripsPerImage get 1 sub {
+ dup TIFFdict /StripOffsets get exch get
+ exch TIFFdict /StripByteCounts get exch get
+ add lengthofinfile gt {(Improper image location) printQuit} if
+ } for
+
+ IMAGEdict /StripsPerImage get 1 gt {
+ IMAGEdict /MultiStripsProc {
+ /InTMPFile edef
+ /InTMPString WOI SPL idiv string def
+ {
+ {
+ InTMPFile InTMPString readstring {
+ exit
+ }{
+ ACTS NOS eq {
+ exit
+ }{
+ PrepareNextStrip
+ /InTMPFile edef
+ dup length 0 eq {pop}{exit} ifelse
+ } ifelse
+ } ifelse
+ } loop
+ } 0 () /SubFileDecode filter
+ } put
+ } if
+
+ /PrepareNextStrip {
+ infile SOF ACTS get setfileposition
+ infile SBC ACTS get () /SubFileDecode filter
+ IMAGEdict /FillOrderProc known {IMAGEdict /FillOrderProc get exec} if
+ IMAGEdict /DCTProc known {IMAGEdict /DCTProc get exec} if
+ IMAGEdict /Decompression known {IMAGEdict /Decompression get exec} if
+ IMAGEdict /CheckStripProc known {IMAGEdict /CheckStripProc get exec} if
+ /ACTS ACTS 1 add def
+ } def
+
+ /NOS IMAGEdict /StripsPerImage get def
+ /RPS TIFFdict /RowsPerStrip get def
+ /SOF TIFFdict /StripOffsets get def
+ /SBC TIFFdict /StripByteCounts get def
+ /NOC IMAGEdict /SamplesPerPixel get def
+ /NRS NOC def % can be changed in ExtraSamplesProc
+ /ONRS NRS def % can be changed by separation parameter
+ /BPS IMAGEdict /BitsPerComponent get def
+ /WOI IMAGEdict /Width get def
+ /HOI IMAGEdict /Height get def
+ /OWOI WOI def % can be changed by reduction parameter
+ /OHOI HOI def % can be changed by reduction parameter
+ /LOS WOI NOC mul BPS mul 8 div ceiling cvi RPS mul def % length of strip
+ /ACTS 0 def
+ /SPL 1 % strings per line (for very wide images)
+ WOI NRS mul 65535 gt {
+ {1 add
+ WOI 1 index mod 0 eq {
+ WOI 1 index idiv NRS mul 65535 lt {exit} if
+ } if
+ } loop
+ dup 17 ge {% beautiful Gaussian number
+ (Very wide image, may be processed slowly\n) printCon
+ } if
+ } if def
+
+ IMAGEdict /DCTProc known {
+ /DCTTO TIFFdict /JPEGTableOffset get def
+ /DCTTL TIFFdict /JPEGTableLength get 2 sub def % without EOI mark
+ /DCTTMPstr 4096 string def
+ infile DCTTO testandsetfileposition
+ /DCTTable infile DCTTL string readstring pop def
+ 0 1 NOS 1 sub {dup % and here without SOI mark
+ SOF exch 2 copy get 2 add put
+ SBC exch 2 copy get 2 sub put
+ } for
+ } if
+
+ PrepareNextStrip
+ IMAGEdict /MultiStripsProc known {IMAGEdict /MultiStripsProc get exec} if
+ IMAGEdict /PredictorProc known {IMAGEdict /PredictorProc get exec} if
+ IMAGEdict /ExtraSamplesProc known {IMAGEdict /ExtraSamplesProc get exec} if
+ IMAGEdict /DataSource 2 index put pop
+
+} def
+
+/Showdict {{exch (\t) print =only (\t) print ==} forall} def
+/ShowTIFFDict {% debugging
+ EPSdict /Verbose get 2 ge {
+ (\n\nTIFF (input) dictionary:\n) print
+ TIFFdict Showdict
+ } if
+} def
+/ShowImageDict {% debugging
+ EPSdict /Verbose get 2 gt {
+ (\n\nImage (inner) dictionary:\n) print
+ IMAGEdict Showdict
+ } if
+} def
+/ShowEPSDict {% debugging
+ EPSdict /Verbose get 2 gt {
+ (\n\nEPS (output) dictionary:\n) print
+ EPSdict Showdict
+ } if
+} def
+
+/ImageImageDict {% for future use
+ 0 0 translate
+ IMAGEdict /XScale get IMAGEdict /YScale get scale
+ IMAGEdict /ColorSpace get aload pop setcolorspace
+ IMAGEdict image
+ showpage
+} def
+
+/concatstrings {
+ exch dup length 2 index length add string % str2 str1 new
+ dup dup 4 2 roll copy % str2 new new new1
+ length 4 -1 roll putinterval
+} bind def
+
+/OTmpStr 256 string def
+/OWrtStr {oufile exch writestring} def
+/writenumber {
+ load OTmpStr cvs OWrtStr (\n) OWrtStr
+} def
+/putnumber {
+ ( /) OWrtStr dup OTmpStr cvs OWrtStr ( ) OWrtStr
+ load OTmpStr cvs OWrtStr (\n) OWrtStr
+} def
+/defnumber {
+ ( /) OWrtStr dup OTmpStr cvs OWrtStr ( ) OWrtStr
+ load OTmpStr cvs OWrtStr ( def\n) OWrtStr
+} def
+/writematrix {
+ ( [ ) OWrtStr load { OTmpStr cvs OWrtStr ( ) OWrtStr} forall (]\n) OWrtStr
+} def
+/putmatrix {
+ ( /) OWrtStr dup OTmpStr cvs OWrtStr writematrix
+} def
+/defarray {
+ ( /) OWrtStr dup OTmpStr cvs OWrtStr ( [ ) OWrtStr
+ load /i 0 def {
+ OTmpStr cvs OWrtStr
+ /i i 1 add def i 8 mod 0 eq {(\n )}{( )} ifelse OWrtStr
+ } forall
+ (] def\n) OWrtStr
+} def
+
+/writepalettecolorspace {
+ ([) OWrtStr ColorSpace {
+ dup type dup /stringtype eq {
+ pop (<) OWrtStr
+ /i 13 def {
+ 16 OTmpStr cvrs dup length 1 eq {(0) OWrtStr} if OWrtStr
+ /i i 1 add def i 33 mod 0 eq { (\n) OWrtStr} if
+ } forall
+ (>) OWrtStr
+ }{
+ /nametype eq {(/) OWrtStr} if
+ OTmpStr cvs OWrtStr
+ } ifelse ( ) OWrtStr
+ } forall (]) OWrtStr
+} def
+
+/movedictentry {EPSdict exch dup IMAGEdict exch get put} def
+/MakeEPSdict {
+ /Height movedictentry
+ /Width movedictentry
+ /BitsPerComponent movedictentry
+ /ImageMatrix movedictentry
+ /XScale movedictentry
+ /YScale movedictentry
+ /ColorSpace movedictentry
+ /Decode movedictentry
+ EPSdict /ColorSpace get length 1 gt
+ EPSdict /PSLevel get 2 lt and {
+ (Can't make Level 1 EPS from TIFF width palette colorspace) printQuit
+ } if
+ EPSdict /PSImagemask get 0 gt
+ EPSdict /BitsPerComponent get 1 eq
+ EPSdict /Decode get length 2 eq and and {
+ EPSdict /PSImagemask get 2 eq {
+ EPSdict /Decode 2 copy get aload 3 1 roll exch 3 -1 roll astore put
+ } if
+ EPSdict /ColorSpace [] put
+ EPSdict /ImageOperator (imagemask\n) put
+ }{
+ EPSdict /ImageOperator (image\n) put
+ } ifelse
+ EPSdict /Reduction known {
+ EPSdict /BitsPerComponent get 8 ne EPSdict /HeaderForm get or {
+ EPSdict /Reduction undef
+ EPSdict /HeaderForm get {
+ (Reduce in header form makes no sense, ignoring `-r'\n) printCon
+ }{
+ (Can't reduce: sample takes less than byte, ignoring `-r'\n) printErr
+ } ifelse
+ }{
+ EPSdict begin
+ /Height Height 1 sub Reduction mul floor 1 add cvi def
+ /Width Width 1 sub Reduction mul floor 1 add cvi def
+ TIFFdict /Orientation get % remake ImageMatrix
+ dup 1 eq { /ImageMatrix [Width 0 0 Height neg 0 Height] def} if
+ dup 2 eq { /ImageMatrix [Width neg 0 0 Height neg Width Height] def} if
+ dup 3 eq { /ImageMatrix [Width neg 0 0 Height Width 0] def} if
+ dup 4 eq { /ImageMatrix [Width 0 0 Height 0 0] def} if
+ dup 5 eq { /ImageMatrix [0 Width neg Height 0 Width] def} if
+ dup 6 eq { /ImageMatrix [0 Width neg Height neg 0 Height Width] def} if
+ dup 7 eq { /ImageMatrix [0 Width Height neg 0 Height 0] def} if
+ 8 eq { /ImageMatrix [0 Width Height 0 0 0] def} if
+ end
+ /OWOI EPSdict /Width get def
+ /OHOI EPSdict /Height get def
+ } ifelse
+ } if
+ EPSdict /OutCompression get dup (CT3) eq exch (CT4) eq or
+ EPSdict /BitsPerComponent get 1 ne and {
+ (CCITTFax compression makes sense only for black-and-white bitmaps, ignoring `-f'\n) printErr
+ EPSdict /OutDataComEncode {} put
+ EPSdict /OutDataComClose {} put
+ EPSdict /OutDataComSource () put
+ } if
+ EPSdict /OutCompression get (JPG) eq
+ EPSdict /BitsPerComponent get 8 ne and {
+ (DCT compression makes sense only for gray, RGB ans CMYK bitmaps, ignoring `-f'\n) printErr
+ EPSdict /OutDataComEncode {} put
+ EPSdict /OutDataComClose {} put
+ EPSdict /OutDataComSource () put
+ } if
+
+ EPSdict /Separation known {
+ EPSdict /ColorSpace get 0 get /DeviceCMYK ne {
+ (Can't separate: mode other than CMYK, ignoring `-s'\n) printErr
+ }{
+ EPSdict /ColorSpace [/DeviceGray] put
+ EPSdict /Decode [1 0] put
+ /ONRS 1 def
+ } ifelse
+ }if
+} def
+
+/WriteDSComments {
+ (%!PS-Adobe-3.0 EPSF-3.0\n) OWrtStr
+ (%%BoundingBox: 0 0 ) OWrtStr
+ ExactBB not {
+ XScale ceiling cvi OTmpStr cvs OWrtStr ( ) OWrtStr
+ YScale ceiling cvi OTmpStr cvs OWrtStr
+ (\n%%HiResBoundingBox: 0 0 ) OWrtStr
+ } if
+ XScale 1000 mul ceiling 1000 div OTmpStr cvs OWrtStr ( ) OWrtStr
+ YScale 1000 mul ceiling 1000 div OTmpStr cvs OWrtStr
+ (\n%%Creator: TIF2EPS ver. 0.79 / ) OWrtStr
+ product OWrtStr ( ) OWrtStr revision OTmpStr cvs OWrtStr (\n) OWrtStr
+} def
+
+/WriteImageParams {
+ /OWOI defnumber
+ /OHOI defnumber
+ /ONRS defnumber
+ /BPS defnumber
+} def
+
+/WriteImageCommand {
+ (0 0 translate\n) OWrtStr
+ XScale OTmpStr cvs OWrtStr ( ) OWrtStr YScale OTmpStr cvs OWrtStr ( scale\n) OWrtStr
+ ColorSpace length 0 ne {
+ ColorSpace length 1 eq {
+ (/) OWrtStr ColorSpace 0 get OTmpStr cvs OWrtStr
+ }{
+ writepalettecolorspace
+ } ifelse ( setcolorspace\n) OWrtStr
+ } if
+ (<<% ImageDictionary\n) OWrtStr
+ ( /ImageType 1\n) OWrtStr
+ /Width putnumber
+ /Height putnumber
+ /ImageMatrix putmatrix
+ ( /DataSource currentfile ) OWrtStr
+ OutDataEncSource OWrtStr OutDataComSource OWrtStr (\n) OWrtStr
+ /BitsPerComponent putnumber
+ /Decode putmatrix
+ PSInterpolate {
+ ( /Interpolate true\n) OWrtStr
+ } if
+ (>>\n) OWrtStr
+ ImageOperator OWrtStr
+} def
+
+/WriteImageCommandOne {
+ (/picstr OWOI string def\n) OWrtStr
+ (0 0 translate\n) OWrtStr
+ XScale OTmpStr cvs OWrtStr ( ) OWrtStr YScale OTmpStr cvs OWrtStr ( scale\n) OWrtStr
+ ColorSpace length 1 eq Decode 0 get 1 eq and {
+ ({1 exch sub} settransfer\n) OWrtStr
+ } if
+ (OWOI OHOI ) OWrtStr
+ ColorSpace length 0 eq {
+ Decode 0 get 1 eq {(true\n)}{(false\n)} ifelse
+ }{
+ (BPS\n)
+ } ifelse OWrtStr
+ /ImageMatrix writematrix
+ ({currentfile picstr readhexstring pop}\n) OWrtStr
+ ONRS 1 eq {
+ ImageOperator
+ }{
+ (false ONRS colorimage\n)
+ } ifelse OWrtStr
+} def
+
+/WriteEPSHeader {
+ EPSdict begin
+ WriteDSComments
+ WriteImageParams
+ PSLevel 2 eq {
+ WriteImageCommand
+ }{
+ WriteImageCommandOne
+ } ifelse
+ end
+} def
+
+/definestring {
+ /dtmpstr () def {
+ /dtmpstr dtmpstr
+ currentfile =string readline not
+ {(Shouldn't happen -- unexpected end of file) printQuit} if
+ (%END) anchorsearch {pop pop pop pop exit} if
+ concatstrings (\n) concatstrings def
+ } loop
+ dtmpstr def
+} def
+
+% BEGIN of FillOrder procedure string
+/FillOrderProcString definestring
+/FillOrderProc {
+ /InFillOrderFile exch def
+ /FillOrderTmpString 255 string def
+ <008040c020a060e0109050d030b070f0088848c828a868e8189858d838b878f8
+ 048444c424a464e4149454d434b474f40c8c4ccc2cac6cec1c9c5cdc3cbc7cfc
+ 028242c222a262e2129252d232b272f20a8a4aca2aaa6aea1a9a5ada3aba7afa
+ 068646c626a666e6169656d636b676f60e8e4ece2eae6eee1e9e5ede3ebe7efe
+ 018141c121a161e1119151d131b171f1098949c929a969e9199959d939b979f9
+ 058545c525a565e5159555d535b575f50d8d4dcd2dad6ded1d9d5ddd3dbd7dfd
+ 038343c323a363e3139353d333b373f30b8b4bcb2bab6beb1b9b5bdb3bbb7bfb
+ 078747c727a767e7179757d737b777f70f8f4fcf2faf6fef1f9f5fdf3fbf7fff>
+ /binv exch def
+ {
+ InFillOrderFile FillOrderTmpString readstring pop
+ dup length 1 sub 0 exch 1 exch {
+ FillOrderTmpString exch binv FillOrderTmpString 2 index
+ get get put
+ } for
+ } 0 () /SubFileDecode filter
+} def
+%END
+% BEGIN of DCTProc procedure string
+/DCTProcString definestring
+/DCTProcInit {
+ /DCTTMPstr 4096 string def
+ infile DCTTO setfileposition
+ /DCTTable infile DCTTL string readstring pop def
+} def
+/DCTProc {
+ /DCTTMPfile exch def /DCTfirsttime true def
+ {DCTfirsttime {
+ /DCTfirsttime false def DCTTable
+ }{
+ DCTTMPfile DCTTMPstr readstring pop
+ } ifelse
+ }
+} def
+%END
+% BEGIN of MultiStrips procedure string
+/MultiStripsProcString definestring
+% Multi Strips Procedure
+/MultiStripsProc {
+ /InTMPFile exch def
+ /InTMPString OWOI SPL idiv string def
+ {
+ {
+ InTMPFile InTMPString readstring {
+ exit
+ }{
+ ACTS NOS eq {
+ exit
+ }{
+ PrepareNextStrip
+ /InTMPFile exch def
+ dup length 0 eq {pop}{exit} ifelse
+ } ifelse
+ } ifelse
+ } loop
+ } 0 () /SubFileDecode filter
+} def
+%END
+% BEGIN of Predictor procedure string
+/PredictorProcString definestring
+% Predictor Procedure
+/PredictorProc {
+ /InPredictorFile exch def
+ /PredictorTmpString OWOI SPL idiv NOC mul string def
+ {
+ /LastPix [ NOC {0} repeat ] def /PredictorCount 0 def
+ InPredictorFile PredictorTmpString readstring pop
+ dup {
+ LastPix PredictorCount NOC mod get add 256 mod dup
+ LastPix exch PredictorCount NOC mod exch put
+ PredictorTmpString PredictorCount 2 index put pop
+ /PredictorCount PredictorCount 1 add def
+ } forall
+ } 0 () /SubFileDecode filter
+} def
+%END
+% BEGIN of ExtraSamples procedure string
+/ExtraSamplesProcString definestring
+% Extra Samples Procedure
+/ExtraSamplesProc {
+ /InExtraSamplesFile exch def
+ /IExtraSamplesString OWOI SPL idiv NOC mul string def
+ /OExtraSamplesString OWOI SPL idiv NRS mul string def
+ {
+ /IExtraSamplesCount 0 def /OExtraSamplesCount 0 def
+ InExtraSamplesFile IExtraSamplesString readstring pop
+ length NOC idiv {
+ OExtraSamplesString OExtraSamplesCount
+ IExtraSamplesString IExtraSamplesCount NRS getinterval
+ putinterval
+ /OExtraSamplesCount OExtraSamplesCount NRS add def
+ /IExtraSamplesCount IExtraSamplesCount NOC add def
+ } repeat
+ OExtraSamplesString
+ } 0 () /SubFileDecode filter
+} def
+%END
+% BEGIN of Recover string
+/RecoverString definestring
+% Recover procedures
+/CheckStripProc {
+ /InCheckStripFile exch def
+ /CheckStripTmpString OWOI SPL idiv NOC mul BPS mul 8 div ceiling cvi string def
+ /CheckStripBytes CheckStripTmpString length SPL mul
+ ACTS NOS 1 sub eq {OHOI RPS ACTS mul sub}{RPS} ifelse mul def
+ {
+ InCheckStripFile CheckStripTmpString readstring pop
+ dup length dup CheckStripBytes gt {
+ pop 0 CheckStripBytes getinterval
+ }{
+ 0 eq CheckStripBytes 0 gt and {
+ pop CheckStripTmpString dup length CheckStripBytes gt {
+ 0 CheckStripBytes getinterval
+ } if
+ } if
+ } ifelse
+ /CheckStripBytes CheckStripBytes 2 index length sub def
+ } 0 () /SubFileDecode filter
+} def
+/MyRunLengthDecode{
+ /MRLETmpString 129 string def
+ /RLEFile exch def
+ {RLEFile read {
+ dup 127 le {
+ 1 add MRLETmpString exch 0 exch getinterval RLEFile exch readstring pop
+ % there should be enough data -- if not decode what is
+ }{
+ 257 exch sub MRLETmpString exch 0 exch getinterval
+ RLEFile read {
+ 0 1 3 index length 1 sub {2 index exch 2 index put} for pop
+ }{
+ () % in case when count=128 and it meaning is EOD -- according
+ % to specification
+ } ifelse
+ } ifelse
+ }{()} ifelse
+ } 0 () /SubFileDecode filter
+} def
+%END
+% BEGIN of Separation string
+/SeparationProcString definestring
+% Separation Procedure
+/SeparationProc {
+ /TmpSepFile exch def /TmpSepString NRS OWOI mul string def
+ {
+ TmpSepFile TmpSepString readstring pop 0
+ SEP NRS 3 index length 1 sub {
+ 2 index exch get
+ 3 copy put pop
+ 1 add
+ } for
+ dup 0 ne {0 exch getinterval}{pop pop ()} ifelse
+ } 0 () /SubFileDecode filter
+} def
+%END
+% BEGIN of PrepareFile string
+/PrepareFileString definestring
+ /TIFFDirectory where {
+ /TIFFDirectory get
+ dup length dup ifn length add string dup dup
+ 4 -1 roll ifn putinterval
+ 0 4 -1 roll putinterval
+ /ifn exch def
+ } if
+ ifn status {
+ pop pop pop pop
+ }{
+ (!!!TIFF input ) print ifn print ( not found!!!) print quit
+ } ifelse
+ /infile ifn (r) file def
+% infile bytesavailable LOT ne
+% infile 4096 LOT 2 copy gt{exch} if pop string readstring pop
+% 0 exch {exch 314159265 mod 3 mul add} forall CRC ne or {
+% (!!!TIFF input ) print ifn print ( was changed!!!) print quit
+% } if
+ /PrepareNextStrip {
+ infile SOF ACTS get setfileposition
+ infile SBC ACTS get () /SubFileDecode filter
+%END
+
+/PrepareTIFFName {
+ /tfn ifn def
+ tfn length 1 sub -1 0 {
+ dup tfn exch get dup 47 eq exch 92 eq or {
+ 1 add tfn exch tfn length 1 index sub getinterval /tfn edef exit
+ } if
+ } for
+} def
+
+/writepreparefilteredfile {
+ /NOS defnumber
+ /SOF defarray
+ /SBC defarray
+ /RPS defnumber
+ /NRS defnumber
+ /NOC defnumber
+ /SPL defnumber
+ /LOS defnumber
+ /LOT defnumber
+ /CRC defnumber
+ (% Procedures for filtering TIFF data\n) OWrtStr
+ IMAGEdict /FillOrderProc known {FillOrderProcString OWrtStr} if
+ IMAGEdict /MultiStripsProc known {MultiStripsProcString OWrtStr} if
+ IMAGEdict /DCTProc known {DCTProcString OWrtStr} if
+ IMAGEdict /PredictorProc known {PredictorProcString OWrtStr} if
+ IMAGEdict /ExtraSamplesProc known {ExtraSamplesProcString OWrtStr} if
+ EPSdict /Recover get {RecoverString OWrtStr} if
+ EPSdict /Separation known {SeparationProcString OWrtStr} if
+ (% Preparing TIFF data source\n) OWrtStr
+ ( /ifn \() OWrtStr tfn OWrtStr (\) def\n) OWrtStr
+ PrepareFileString OWrtStr
+ IMAGEdict /FillOrderProc known {( FillOrderProc\n) OWrtStr} if
+ IMAGEdict /DCTProc known {( DCTProc\n) OWrtStr} if
+ IMAGEdict /DecompressionString known {
+ IMAGEdict /DecompressionString get OWrtStr
+ } if
+ EPSdict /Recover get {( CheckStripProc\n) OWrtStr} if
+ ( /ACTS ACTS 1 add def\n) OWrtStr
+ ( } def\n) OWrtStr % end of PrepareNextStrip procedure
+ EPSdict /Separation known {
+ ( /SEP ) OWrtStr EPSdict /Separation get OTmpStr cvs OWrtStr
+ ( def\n) OWrtStr
+ } if
+ ( /ACTS 0 def\n) OWrtStr
+ IMAGEdict /DCTProc known {
+ /DCTTO defnumber
+ /DCTTL defnumber
+ (DCTProcInit\n) OWrtStr
+ } if
+ ( PrepareNextStrip\n) OWrtStr
+ IMAGEdict /MultiStripsProc known {( MultiStripsProc\n) OWrtStr} if
+ IMAGEdict /PredictorProc known {( PredictorProc\n) OWrtStr} if
+ IMAGEdict /ExtraSamplesProc known {( ExtraSamplesProc\n) OWrtStr} if
+ EPSdict /Separation known {( SeparationProc\n) OWrtStr} if
+ ( /filteredfile exch def\n) OWrtStr
+ (% End of preparing TIFF data source\n) OWrtStr
+} def
+
+/WriteHeaderEPS {
+ EPSdict begin
+ PrepareTIFFName
+ WriteDSComments
+ (%%DocumentNeededResources: file ) OWrtStr tfn OWrtStr (\n) OWrtStr
+ WriteImageParams
+ writepreparefilteredfile
+ WriteImageCommand
+ end
+ WriteEPSTrailer
+} def
+
+/ticnum 0 def /tacnum 0 def
+/TicTac {
+ /ticnum ticnum 1 add def {
+ ticnum HOI div tacnum 40 div ge {
+ tacnum 10 mod 0 eq {(:)}{(.)} ifelse printCon flush
+ /tacnum tacnum 1 add def
+ }{exit} ifelse
+ } loop % ;-)
+} def
+
+/WriteEPSData {
+ EPSdict begin
+ /ICopyFile IMAGEdict /DataSource get def
+ /OCopyFile OutDataEncEncode OutDataComEncode def
+ /IOutString WOI SPL idiv NRS mul string def
+ EPSdict /Reduction known {
+ EPSdict /Separation known {
+ /MSEP Separation def
+ /get_write_proc {get write} def
+ }{
+ /MSEP 0 def
+ /get_write_proc {NRS getinterval writestring} def
+ } ifelse
+ /ACTH 0 def /ACTNH 0 def
+ HOI {
+ ACTH Reduction mul ACTNH ge {
+ /ACTW 0 def /ACTNW 0 def
+ SPL {
+ ICopyFile IOutString readstring pop pop
+ /ACTSW MSEP def
+ WOI SPL idiv {
+ ACTW Reduction mul ACTNW ge {
+ OCopyFile IOutString ACTSW get_write_proc
+ /ACTNW ACTNW 1 add def
+ } if
+ /ACTW ACTW 1 add def /ACTSW ACTSW NRS add def
+ } repeat
+ } repeat
+ /ACTNH ACTNH 1 add def
+ }{
+ SPL {ICopyFile IOutString readstring pop pop} repeat
+ } ifelse
+ /ACTH ACTH 1 add def
+ TicTac
+ } repeat
+ }{
+ EPSdict /Separation known {
+ OCopyFile IOutString 2 copy
+ HOI {
+ SPL {
+ ICopyFile IOutString readstring pop pop
+ Separation NRS dup WOI SPL idiv mul 1 sub {
+ get write 2 copy
+ } for
+ } repeat
+ TicTac
+ } repeat pop pop pop pop
+ }{
+ OCopyFile ICopyFile IOutString
+ HOI {
+ SPL {
+ 3 copy readstring pop writestring
+ } repeat
+ TicTac
+ } repeat pop pop pop
+ } ifelse
+ } ifelse
+ OCopyFile flushclosefile OutDataComClose OutDataEncClose
+ end
+} def
+
+/WriteEPSTrailer {
+ (\n%%EOF) OWrtStr
+ oufile flushclosefile
+} def
+
+/truncext {% (filename.ext) truncext (filename)
+ /fnm edef
+ fnm length 1 sub -1 0 {
+ dup fnm exch get dup 46 eq {
+ pop fnm exch 0 exch getinterval /fnm edef exit
+ } if
+ dup 47 eq {pop exit} if
+ 92 eq {exit} if
+ pop
+ } for
+ fnm
+} def
+
+/CheckFiles {
+ EPSdict /InputFilename known {
+ EPSdict /InputFilename get /ifn edef
+ ifn status {
+ pop pop pop pop
+ }{
+ ifn (.tif) concatstrings status {
+ pop pop pop pop /ifn ifn (.tif) concatstrings def
+ }{
+ (Input file not found) printQuit
+ } ifelse
+ } ifelse
+ }{
+ (Input filename unknown) printQuit
+ } ifelse
+ /infile ifn (r) file def
+ /lengthofinfile infile bytesavailable def
+ /LOT lengthofinfile def
+ infile 4096 LOT 2 copy gt{exch} if pop string readstring pop
+ 0 exch {exch 314159265 mod 3 mul add} forall /CRC edef
+ infile 0 setfileposition
+
+ EPSdict /OutputFilename known {
+ EPSdict /OutputFilename get
+ }{
+ ifn truncext EPSdict /EPSextension get concatstrings
+ } ifelse
+ /ofn edef
+
+ ifn ofn eq {
+ (Input and output filenames must differ) printQuit
+ } if
+ EPSdict /Overwrite get 1 ne {
+ ofn status {
+ EPSdict /Overwrite get 0 eq {
+ pop pop pop pop
+ (Output file exists \(use option `-o' to overwrite\)) printQuit
+ }{
+ % Using `referenced' (interpreted by Ghostscript as the `modification
+ % time', which doesn't comply with the specification of PostScript)
+ % instead of `created' (the `creation time') is most preferable
+ % for comparison.
+ pop 3 1 roll pop pop
+ ifn status pop pop 3 1 roll pop pop
+ gt {
+ (Output file is newer than source \(use option `-o' to overwrite\)) printQuit
+ } if
+ } ifelse
+ } if
+ } if
+
+} def
+
+/MyASCII85Encode{
+ /InnerASCIIstring 4096 string def
+ {pop (%) anchorsearch {pop oufile ( %) writestring} if
+ {(\n%) search not {exit} if
+ oufile exch writestring pop oufile (\n %) writestring} loop
+ oufile exch writestring InnerASCIIstring} /NullEncode filter
+ dup /InnerASCIIfile edef /ASCII85Encode filter
+} def
+
+/MyASCIIHexEncode{
+ /InnerASCIIstring 4096 string def
+ {pop (>) search {exch pop exch pop} if
+ oufile exch writestring InnerASCIIstring}
+ /ASCIIHexEncode filter
+} def
+
+/MyRunLengthDecode{
+ /MRLETmpString 129 string def
+ /RLEFile exch def
+ {RLEFile read {
+ dup 127 le {
+ 1 add MRLETmpString exch 0 exch getinterval RLEFile exch readstring pop
+ % there should be enough data -- if not decode what is
+ }{
+ 257 exch sub MRLETmpString exch 0 exch getinterval
+ RLEFile read {
+ 0 1 3 index length 1 sub {2 index exch 2 index put} for pop
+ }{
+ () % in case when count=128 and it meaning is EOD -- according
+ % to specification
+ } ifelse
+ } ifelse
+ }{()} ifelse
+ } 0 () /SubFileDecode filter
+} def
+
+/PrepareOutParams {
+ EPSdict /Overwrite get 2 gt {(Odd option -o#\n) printErr} if
+ EPSdict /PSLevel get dup 2 eq {pop}{
+ 1 eq {
+ EPSdict /OutCompression get (NON) ne {
+ EPSdict /OutCompression (NON) put
+ } if
+ EPSdict /OutCoding get (HEX) ne {
+ EPSdict /OutCoding (HEX) put
+ } if
+ EPSdict /HeaderForm get {
+ EPSdict /HeaderForm false put
+ } if
+ EPSdict /PSInterpolate get {
+ EPSdict /PSInterpolate false put
+ } if
+ }{
+ (Only Level 1 and 2 are supported -- assuming Level 2\n) printErr
+ EPSdict /PSLevel 2 put
+ } ifelse
+ } ifelse
+ EPSdict /Verbose get 1 ge {
+ /printCon {print} def
+ }{
+ /printCon {pop} def
+ } ifelse
+ % Coding
+ EPSdict /OutCoding get (A85) eq {
+ EPSdict /SpecialASCII85 known {
+ EPSdict /OutDataEncEncode /MyASCII85Encode load put
+ EPSdict /OutDataEncClose {InnerASCIIfile flushclosefile} put
+ }{
+ EPSdict /OutDataEncEncode {oufile /ASCII85Encode filter} put
+ EPSdict /OutDataEncClose {} put
+ } ifelse
+ EPSdict /OutDataEncSource (/ASCII85Decode filter) put
+ } if
+ EPSdict /OutCoding get (HEX) eq {
+ EPSdict /PSLevel get 1 eq {
+ EPSdict /OutDataEncEncode /MyASCIIHexEncode load put
+ EPSdict /OutDataEncClose {} put
+ EPSdict /OutDataEncSource () put
+ }{
+ EPSdict /OutDataEncEncode {oufile /ASCIIHexEncode filter} put
+ EPSdict /OutDataEncClose {} put
+ EPSdict /OutDataEncSource (/ASCIIHexDecode filter) put
+ } ifelse
+ } if
+ % Compression
+ EPSdict /OutCompression get (RLE) eq {
+ EPSdict /OutDataComEncode {dup /COMPRfile edef 0 /RunLengthEncode filter} put
+ EPSdict /OutDataComClose {COMPRfile flushclosefile} put
+ EPSdict /OutDataComSource ( /RunLengthDecode filter) put
+ } if
+ EPSdict /OutCompression get (FLA) eq {
+ EPSdict /OutDataComEncode {dup /COMPRfile edef /FlateEncode filter} put
+ EPSdict /OutDataComClose {COMPRfile flushclosefile} put
+ EPSdict /OutDataComSource ( /FlateDecode filter) put
+ } if
+ EPSdict /OutCompression get (LZW) eq {
+ EPSdict /OutDataComEncode {dup /COMPRfile edef /LZWEncode filter} put
+ EPSdict /OutDataComClose {COMPRfile flushclosefile} put
+ EPSdict /OutDataComSource ( /LZWDecode filter) put
+ } if
+ EPSdict /OutCompression get (L-P) eq {
+ EPSdict /OutDataComEncode {dup /COMPRfile edef <</Predictor 2 /Columns OWOI
+ /Colors ONRS /BitsPerSample BPS>> /LZWEncode filter} put
+ EPSdict /OutDataComClose {COMPRfile flushclosefile} put
+ EPSdict /OutDataComSource ( <</Predictor 2 /Columns OWOI /Colors ONRS /BitsPerSample BPS>> /LZWDecode filter) put
+ } if
+ EPSdict /OutCompression get (CT3) eq {
+ EPSdict /OutDataComEncode {dup /COMPRfile edef <</K 0 /Columns OWOI>> /CCITTFaxEncode filter} put
+ EPSdict /OutDataComClose {COMPRfile flushclosefile} put
+ EPSdict /OutDataComSource ( <</K 0 /Columns OWOI>> /CCITTFaxDecode filter) put
+ } if
+ EPSdict /OutCompression get (CT4) eq {
+ EPSdict /OutDataComEncode {dup /COMPRfile edef <</K -1 /Columns OWOI>> /CCITTFaxEncode filter} put
+ EPSdict /OutDataComClose {COMPRfile flushclosefile} put
+ EPSdict /OutDataComSource ( <</K -1 /Columns OWOI>> /CCITTFaxDecode filter) put
+ } if
+ EPSdict /OutCompression get (JPG) eq {
+ EPSdict /OutDataComEncode {dup /COMPRfile edef <</Columns OWOI /Rows OHOI /Colors ONRS>> /DCTEncode filter} put
+ EPSdict /OutDataComClose {COMPRfile flushclosefile} put
+ EPSdict /OutDataComSource ( /DCTDecode filter) put
+ } if
+ EPSdict /OutCompression get (NON) eq {
+ EPSdict /OutDataComEncode {} put
+ EPSdict /OutDataComClose {} put
+ EPSdict /OutDataComSource () put
+ } if
+ EPSdict /HeaderForm get {
+ EPSdict /OutDataEncSource (pop filteredfile) put
+ EPSdict /OutCompression get (NON) ne {
+ (For header EPSs compression makes no sense, ignoring `-f'\n) printErr
+ EPSdict /OutDataComSource () put
+ } if
+ } if
+} def
+
+/ProcessBooleanFlag {
+ mark 3 index dup
+ dup (+) eq exch dup (1) eq exch () eq or or {true exch} if
+ dup (-) eq exch (0) eq or {false} if
+ counttomark 1 eq {
+ exch pop EPSdict 3 1 roll put
+ pop pop
+ }{
+ cleartomark pop
+ (Odd option ) printErr printErr printErr (\n) printErr
+ } ifelse ()
+} def
+/ProcessIntFlag {
+ mark 3 index
+ dup dup (-) eq exch (0) eq or {0 exch} if
+ dup dup (+) eq exch dup (1) eq exch () eq or or {1 exch} if
+ dup (2) eq {2 exch} if
+ dup (3) eq {3 exch} if
+ (4) eq {4} if
+ counttomark 1 eq {
+ exch pop EPSdict 3 1 roll put
+ pop pop
+ }{
+ cleartomark pop
+ (Odd option ) printErr printErr printErr (\n) printErr
+ } ifelse ()
+} def
+
+/FixHeaderForm {/HeaderForm ProcessBooleanFlag} def
+/FixPSInterpolate {/PSInterpolate ProcessBooleanFlag} def
+/FixBB {/ExactBB ProcessBooleanFlag} def
+/FixRecover {/Recover ProcessBooleanFlag} def
+/FixImagemask {/PSImagemask ProcessIntFlag} def
+/FixOverwrite {/Overwrite ProcessIntFlag} def
+/FixVerbose {/Verbose ProcessIntFlag} def
+/FixLevel {/PSLevel ProcessIntFlag} def
+/FixPageN {
+ pop {cvi} stopped {
+ (Page number must be a number) printQuit
+ } if
+ dup 0 ge {
+ EPSdict /PageNumber 2 index put pop
+ }{
+ (Negative page number -p) printErr =string cvs printQuit
+ } ifelse ()
+} def
+/FixReduction {
+ pop {cvr} stopped {
+ (Reduction factor must be a number) printQuit
+ } if
+ dup dup 1 le exch 0 gt and {
+ EPSdict /Reduction 2 index put pop
+ }{
+ (Improper reduction factor -r) printErr =string cvs printQuit
+ } ifelse ()
+} def
+/FixResolution {
+ pop (x) search dup not {pop (X) search} if
+ {
+ checkresolution EPSdict /XResolution 2 index put pop pop
+ checkresolution EPSdict /YResolution 2 index put pop
+ }{
+ checkresolution EPSdict /XResolution 2 index put
+ EPSdict /YResolution 2 index put pop
+ } ifelse ()
+} def
+/checkresolution {
+ {cvr} stopped {(Resolution must be a number) printQuit} if
+ dup 1 lt {(Resolution can't be lower than 1 dpi) printQuit} if
+} def
+/FixSeparation {
+ pop
+ dup dup (1) eq exch dup (c) eq exch (C) eq or or {EPSdict /Separation 0 put EPSdict /EPSextension (.c) put} if
+ dup dup (2) eq exch dup (m) eq exch (M) eq or or {EPSdict /Separation 1 put EPSdict /EPSextension (.m) put} if
+ dup dup (3) eq exch dup (y) eq exch (Y) eq or or {EPSdict /Separation 2 put EPSdict /EPSextension (.y) put} if
+ dup dup (4) eq exch dup (k) eq exch (K) eq or or {EPSdict /Separation 3 put EPSdict /EPSextension (.k) put} if
+ EPSdict /Separation known not {
+ (Improper separation -s) printErr printQuit
+ }{pop} ifelse ()
+} def
+/FixFilter {
+ pop {
+ 1 string dup 0 3 index put exch pop
+ dup dup (f) eq exch (F) eq or {EPSdict /OutCompression (FLA) put} if
+ dup dup (l) eq exch (L) eq or {EPSdict /OutCompression (LZW) put} if
+ dup dup (p) eq exch (P) eq or {EPSdict /OutCompression (L-P) put} if
+ dup dup (r) eq exch (R) eq or {EPSdict /OutCompression (RLE) put} if
+ dup (3) eq {EPSdict /OutCompression (CT3) put} if
+ dup (4) eq {EPSdict /OutCompression (CT4) put} if
+ dup dup (j) eq exch (J) eq or {EPSdict /OutCompression (JPG) put} if
+ dup dup (n) eq exch (N) eq or {EPSdict /OutCompression (NON) put} if
+ dup dup (h) eq exch (H) eq or {EPSdict /OutCoding (HEX) put} if
+ (8) eq {EPSdict /OutCoding (A85) put} if
+ } forall ()
+} def
+/FixFileNames {
+ EPSdict /InputFilename known {
+ EPSdict /OutputFilename known {
+ (Bad parametr ) printErr printErr (\n) printErr
+ }{
+ EPSdict /OutputFilename 2 index put pop
+ } ifelse
+ }{
+ EPSdict /InputFilename 2 index put pop
+ } ifelse
+} def
+
+/SetDefaultParams {
+ EPSdict /OutCoding (A85) put
+ EPSdict /OutCompression (NON) put
+ EPSdict /EPSextension (.eps) put
+ EPSdict /HeaderForm false put
+ EPSdict /PSInterpolate false put
+ EPSdict /ExactBB true put
+ EPSdict /Recover false put
+ EPSdict /Overwrite 0 put
+ EPSdict /Verbose 1 put
+ EPSdict /PSImagemask 0 put
+ EPSdict /PSLevel 2 put
+} def
+
+/ProcessParams {
+ SetDefaultParams
+ {
+ (-f) anchorsearch {FixFilter} if (-F) anchorsearch {FixFilter} if
+ (-r) anchorsearch {FixReduction} if (-R) anchorsearch {FixReduction} if
+ (-d) anchorsearch {FixResolution} if (-D) anchorsearch {FixResolution} if
+ (-s) anchorsearch {FixSeparation} if (-S) anchorsearch {FixSeparation} if
+ (-v) anchorsearch {FixVerbose} if (-V) anchorsearch {FixVerbose} if
+ (-l) anchorsearch {FixLevel} if (-L) anchorsearch {FixLevel} if
+ (-p) anchorsearch {FixPageN} if (-P) anchorsearch {FixPageN} if
+ (-o) anchorsearch {FixOverwrite} if (-O) anchorsearch {FixOverwrite} if
+ (-h) anchorsearch {FixHeaderForm} if (-H) anchorsearch {FixHeaderForm} if
+ (-e) anchorsearch {FixRecover} if (-E) anchorsearch {FixRecover} if
+ (-b) anchorsearch {FixBB} if (-B) anchorsearch {FixBB} if
+ (-i) anchorsearch {FixPSInterpolate} if (-I) anchorsearch {FixPSInterpolate} if
+ (-m) anchorsearch {FixImagemask} if (-M) anchorsearch {FixImagemask} if
+ (-) anchorsearch {pop (Unknown option -) printErr printErr (\n) printErr ()} if
+ dup () eq {pop}{FixFileNames} ifelse
+ } forall
+ PrepareOutParams
+ CheckFiles
+} def
+
+/TIFFtoEPS {
+ ProcessParams
+ ReadHeader
+ PrepareTAGsDictionary
+ ReadIFDs
+ ShowTIFFDict
+ ProcessImageDict
+ ShowImageDict
+% ImageImageDict quit
+ MakeEPSdict
+ ShowEPSDict
+ (Converting ) printCon ifn printCon
+ EPSdict /HeaderForm get {( into header )}{( into )} ifelse
+ printCon ofn printCon (.\n) printCon flush
+ /oufile ofn (w) file def
+ EPSdict /HeaderForm get {
+ WriteHeaderEPS
+ }{
+ realtime
+ WriteEPSHeader
+ WriteEPSData
+ WriteEPSTrailer
+ realtime exch sub 1000 div OTmpStr cvs
+ (\nProcessing time ) printCon printCon (s.\n) printCon
+ } ifelse
+} def
+
+% BEGIN of usage definition
+/UsageString definestring
+
+This is tif2eps -- a TIFF to EPS translator (ver. 0.79)
+
+Usage: gs [-dNODISPLAY] [-q] -- tif2eps.ps TIFF_name [EPS_name] [options]
+Options:
+ -f# -- output filtering, #=[compression][encoding], where
+ currently implemented compressions:
+ f - Flate, l - LZW, p - LZW with predictor, r - RLE,
+ 3 - CCITTFax group 3, 4 - CCITTFax group 4 (two-dimensional),
+ j - DCT (JPEG standard), n - none, or empty (default is n)
+ currently implemented encodings:
+ 8 - ASCII85, h - HEX, or empty (default is 8)
+ -d# -- override resolution (in dpi, X_RESxY_RES form allowed)
+ -o# -- overwrite output file: 0 - not (default), 1 - yes, 2 - if older
+ -l# -- Postscript Level of output EPS: 1 - Level 1, 2 - Level 2
+ -m# -- operator used for monochrome bitmaps: 0 - image (default),
+ 1 - imagemask, 2 - inversed imagemask
+ -p# -- convert # image (page) of multi-page TIFF (0 - first page)
+ -r# -- reduction (scaling) factor, 0<#<=1
+ -s# -- separation, #=1, 2, 3, 4, or c, m, y, k
+ -v# -- verbose level: 0 - off , 1 - basic (default), 2 - elaborate
+ -b* -- use exact (non-integer) BoundingBox comment format; otherwise
+ HiResBoundingBox is additionally written out (default is +)
+ -e* -- recover errors (special RLE filter, CCITTFax recover)
+ -h* -- write `header' EPS (which reads and interpretes TIFF)
+ -i* -- set `/Interpolate' entry to true in EPS image
+ where asterisk denotes a switch:
+ on: + or 1 (or empty)
+ off: - or 0 (default if not specified otherwise)
+%END of usage definition
+
+% Check for command line arguments.
+[ shellarguments { ] dup length 1 ge {
+ TIFFtoEPS
+ }{
+ UsageString print
+ } ifelse
+}{pop} ifelse
+flush quit
+
+%EOF