[lug] eps to tiff file

Tkil tkil at scrye.com
Tue Oct 19 14:12:54 MDT 1999


[excerpt from beginning of file:]

| {\rtf1\mac\ansicpg10000\uc1 \deff0
   ^^^^^

this file is not a postscript file; it's an RTF ("rich text format")
file.  you will have to open it in a program (typically, a word
processor) that understands the format.  it doesn't immediately look
like it has an image in it, but it's been long enough since i've
played with RTF (two years?) that i can't be sure.  note that linux
"file" is smart enough to figure it out:

| $ file cover.eps
| cover.eps: Rich Text Format data, version 1, Apple Macintosh
| $ rpm -qf `which file`
| file-3.26-6

for future reference, postscript files should always start with:

| %!PS-Adobe-x.y

where "x.y" is the version of the postscript "document structuring
conventions".  EPSF ("encapsulated postscript file") probably has its
own header; let me see if my red book enumerates what it should be...

| %!PS-Adobe-3.0 EPSF-3.0

so you just add it as a keyword.

uh, gross!  looking further through this document, there is some
embedded postscript.  nasty.  anyway, having said all that, let's see
what staroffice can do with that rtf document...

ok, well, it's just an rtf version of the postscript program text.
which is silly, but i remember that ms word on the mac has a
"postscript" style, which you can use to embed postscript directly
into a document.  cute trick but rather non-portable.

having said that, staroffice happily saved it to a text file, so now i 
have the expected text:

| %!PS-Adobe-3.0 EPSF-3.0
| %%BoundingBox: 34 382 582 720
| %%Title: (fax_cover_half_size.eps)
| ...

much better.  well, i tried it against ghostview, and no go.  nasty.
ah, much better, the command-line "gs" program succeeded:

| echo "quit" | \
|    gs -sDEVICE=pnggray -r200 -sOutputFile=cover-gray.pbm cover-epsf.txt

the ghostscript installed on my (redhat 6.0) system has a bevy of TIFF 
formats.  "gs -?" lists:

| Available devices:
|    tiffcrle tiffg3 tiffg32d tiffg4 tifflzw tiffpack tiff12nc tiff24nc

so i'm not entirely sure which one to use.  i tried tiffg4, and it
seemed to produce a valid file, but it didn't look that great -- some
snowing and speckling.  ah-ha!  the two graphics are actually slightly 
greyscale and off-white, so it was dithering to black and white.  let
me see if i can make it better...

yes, using the "pnggray" output filter works well, and the file size
isn't atrocious, either:

| $ ls -al cover*
| -rw-rw-r--   1 tkil     tkil        66850 Oct 19 14:08 cover-16m.png
| -rw-rw-r--   1 tkil     tkil       234696 Oct 19 13:36 cover-epsf.txt
| -rw-rw-r--   1 tkil     tkil        45394 Oct 19 14:09 cover-gray.png
| -rw-rw-r--   1 tkil     tkil        27355 Oct 19 14:06 cover.png
| -rw-r--r--   1 tkil     tkil       462478 Oct 19 13:17 cover.rtf
| -rw-rw-r--   1 tkil     tkil        17771 Oct 19 13:52 cover.tiffg4

so if you know what format you want, you're set.  looking at 300dpi
version (instead of 200dpi, see the "-r" switch to 'gs') yields a
cover-gray.png that is about 75k.  the gimp opens it happily.

and i think this answers your question.  the technique you have to
use:

1. extract the pure text EPSF content from the RTF file.

2. convert the EPSF into a raster format, either directly into TIFF,
   or into an intermediate format that you will convert to TIFF using
   some tool other than the ghostview output filters.

2a. if you chose so in (2), convert your intermediate data to TIFF of
    the appropriate format.

happy hacking,
t.





More information about the LUG mailing list