[comp.lang.postscript] PostScript to Encapsulated PostScript?

fyl@ssc.UUCP (Phil Hughes) (06/07/90)

This must have been asked before ..., but anyone have something
to read a PostScript file and generate EPS?  We have a bunch
of graphics that were generated either by hand in PostScript or
on an Atari that we would like to include in a program that allows
the inclusion of EPS.

-- 
Phil Hughes, SSC, Inc. P.O. Box 55549, Seattle, WA 98155  (206)FOR-UNIX
     uunet!pilchuck!ssc!fyl or attmail!ssc!fyl            (206)527-3385

jeffe@eniac.seas.upenn.edu (George J. Jefferson) (06/07/90)

In article <810@ssc.UUCP> fyl@ssc.UUCP (Phil Hughes) writes:
>This must have been asked before ..., but anyone have something
>to read a PostScript file and generate EPS?  We have a bunch

This question gets asked alot. - but I havn't seen an answer yet.

a) cant be done
b) its a well kept secret
c) its in the frequent questions thing and i'll never hear the end of it

if a) somebody work on it, if b) somebody post it , if c) 'oh never mind'





George Jefferson    jeffe@eniac.seas.upenn.edu   george@sol1.lrsm.upenn.edu

bochner@flare.harvard.EDU (Harry Bochner) (06/08/90)

My understanding is that a full, general solution is difficult or impossible. 
EPS has to promise not to interfere with what's going on on the rest of the
page: if the PS program you're trying to incorporate doesn't obey this, for
instance if it erases part of the page, you're going to be have to find a
different way to get the same effect, and I don't see a general algorithm for
doing that. The problem gets worse yet if the Postscript code breaks the rules
or plays games with things in the system dicts.

On the other hand, what I've often seen here is reasonably clean PostScript
that already passes as EPS even if it wasn't meant to. The only problem then
is that the programs that want to incorporate it are looking for a BoundingBox
comment, an optional but highly desirable feature of the EPS standard. So in
many cases all we really need is an automatic way to calculate the
BoundingBox. A program called bb.ps that almost works has floating around for
a while, and someone (cosell@bbn.com?) has been working hard just lately on
getting the glitches out of this code. If he succeeds it will be a big help,
so let's all encourage him ...

Harry Bochner
bochner@endor.harvard.edu

domae@heat.nrtc.northrop.com (Terry Domae) (06/08/90)

As I understand the problem you need to somehow send your postscript to
a postscript engine (either a postscript laser printer or a postscript
interpreter), then receive the rasterized picture back from that engine.

If you want to do the former (send the output to a laser printer),
what you need to do is then somehow get the name of the Dict entry or
variable which contains the raster image, and write a postscript
routine to type it back to you.  The problem I have is that I can
find nobody who is willing to say anything about the specific internals
of the laserwriter's (specifically a way to get ahold of that
rasterized page).  In the postscript language definition, there are
ways to change the size and character of this raster memory but no way
to get a real handle on that buffer.

There are some commercial packages which will, on a macintosh, send
your postscript file to a laserwriter and get back the image and convert 
that image to EPS format for you.  That package is Smartart by Emerald City
Software (now an Adobe company).

The routine they use is a closly held secret.  But, I suppose you 
could monitor the appletalk and cut out the routine, but I'm sure this
violates your licence of the package.

There are also many postscript interpreters which you can get other
raster images from, but they won't always produce the same results
as your print engine (different fonts, version of postscript, ...).

Terry Domae
Northrop Research and Technology Center

Terry Domae 

domae@heat.nrtc.northrop.com (Terry Domae <tdomae>) (06/08/90)

As I understand the problem you need to somehow send your postscript to
a postscript engine (either a postscript laser printer or a postscript
interpreter), then receive the rasterized picture back from that engine.

If you want to do the former (send the output to a laser printer),
what you need to do is then somehow get the name of the Dict entry or
variable which contains the raster image, and write a postscript
routine to type it back to you.  The problem I have is that I can
find nobody who is willing to say anything about the specific internals
of the laserwriter's (specifically a way to get ahold of that
rasterized page).  In the postscript language definition, there are
ways to change the size and character of this raster memory but no way
to get a real handle on that buffer.

There are some commercial packages which will, on a macintosh, send
your postscript file to a laserwriter and get back the image and convert 
that image to EPS format for you.  That package is Smartart by Emerald City
Software (now an Adobe company).

The routine they use is a closly held secret.  But, I suppose you 
could monitor the appletalk and cut out the routine, but I'm sure this
violates your licence of the package.

There are also many postscript interpreters which you can get other
raster images from, but they won't always produce the same results
as your print engine (different fonts, version of postscript, ...).


Terry Domae 

dplatt@coherent.com (Dave Platt) (06/08/90)

In article <25789@netnews.upenn.edu> jeffe@eniac.seas.upenn.edu.UUCP (George J. Jefferson) writes:
> >This must have been asked before ..., but anyone have something
> >to read a PostScript file and generate EPS?  We have a bunch
> 
> This question gets asked alot. - but I havn't seen an answer yet.
> 
> a) cant be done
> b) its a well kept secret
> c) its in the frequent questions thing and i'll never hear the end of it

It can be done in many cases, I believe, using Glenn Reid's "Distill"
program.  Distill sends a PostScript file to a networked LaserWriter,
prepending a procset which intercepts the low-level drawing
operations and sends them back to the Mac.  Its primary purpose is to
"distill" PostScript files which are to be printed frequenty... in
effect expanding all of their customized PostScript operators into
simple move-and-draw commands which will execute quite quickly.

As a pleasant side-effect, Distill also calculates the bounding box for
the image (essential information for placing an EPS file correctly).

As an experiment, I took a working EPS file I had sitting around (our
corporate logo), stripped off the "EPS-1.2" from the %!PS header,
removed the %%Bounding-Box and similar comments, stripped out the Mac
preview information, and then ran the resulting file through Distill.

The resulting file was not EPS-compatible... but only two manual tweaks
were needed to correct the incompatibility:

1) Change the first line to read "%!PS-Adobe-2.0 EPS-1.2".

2) Delete the "%%Bounding-box: (atend)" line from the beginning of the
   file, and replace it with the real "%%Bounding-box" line from the end
   of the file.

With these two changes in place, FrameMaker (on a Sun SparcStation) was
willing to import the file into a document, and printed it correctly.
There was no preview information present on the screen... the anchored
rectangle was blank... but that didn't really present a problem.

The Mac version of Distill is probably available in the /info-mac
archives at SUMEX-AIM.Stanford.Edu.  I imagine that there may be a Unix
version available, but I'm not at all sure where to find it.

I've only tried to distill one file into EPS... but the chances are
reasonably good that it'd work for you.
-- 
Dave Platt                                             VOICE: (415) 493-8805
  UUCP: ...!{ames,apple,uunet}!coherent!dplatt   DOMAIN: dplatt@coherent.com
  INTERNET:       coherent!dplatt@ames.arpa,  ...@uunet.uu.net 
  USNAIL: Coherent Thought Inc.  3350 West Bayshore #205  Palo Alto CA 94303

news@netnews.upenn.edu (USENET News System) (06/08/90)

>The Mac version of Distill is probably available in the /info-mac
>archives at SUMEX-AIM.Stanford.Edu.  I imagine that there may be a Unix
                                                                    ^^^^
>version available, but I'm not at all sure where to find it.
 ^^^^^^^
From: jeffe@eniac.seas.upenn.edu (George J. Jefferson)
Path: eniac.seas.upenn.edu!jeffe

Somebody confirm this - this would be very nice to have.

Do I understand correctly that Distill brings back a ps file containing well
behaved primitives rather than a raster image?



George Jefferson    jeffe@eniac.seas.upenn.edu   george@sol1.lrsm.upenn.edu

cet1@cl.cam.ac.uk (C.E. Thompson) (06/08/90)

In article <3151@husc6.harvard.edu> bochner@flare.harvard.EDU (Harry Bochner) writes:
>  ... the programs that want to incorporate it are looking for a BoundingBox
>comment, an optional but highly desirable feature of the EPS standard. 

Actually, the BoundingBox structure comment is compulsory in an EPS file. 

Chris Thompson
JANET:    cet1@uk.ac.cam.phx
Internet: cet1%phx.cam.ac.uk@nsfnet-relay.ac.uk

bochner@flare.harvard.EDU (Harry Bochner) (06/09/90)

In article <7710@gremlin.nrtc.northrop.com>,
domae@heat.nrtc.northrop.com (Terry Domae <tdomae>) writes:
|>As I understand the problem you need to somehow send your postscript to
|>a postscript engine (either a postscript laser printer or a postscript
|>interpreter), then receive the rasterized picture back from that engine.

No, this isn't the issue. The EPS standard defines a way to include a bitmap
in the comments, but this is optional, and shouldn't be required by programs
that import EPS. FrameMaker, for instance, will use the bitmap if it's
provided,
so that the user can see an approximation of the included graphics. but
if there's
no bitmap (and if there is a BoundingBox), it will still give you a rectangular
frame that you can use to position the graphics.
In other words, getting the rasterized picture is lovely if you can do it, but
it isn't necessary for the things we need EPS for.

Harry Bochner
bochner@endor.harvard.edu

glenn@heaven.woodside.ca.us (Glenn Reid) (06/09/90)

In article <25818@netnews.upenn.edu> jeffe@eniac.seas.upenn.edu.UUCP (George J. Jefferson) writes:
>>The Mac version of Distill is probably available in the /info-mac
>>archives at SUMEX-AIM.Stanford.Edu.  I imagine that there may be a Unix
>                                                                    ^^^^
>>version available, but I'm not at all sure where to find it.
> ^^^^^^^
>From: jeffe@eniac.seas.upenn.edu (George J. Jefferson)
>Path: eniac.seas.upenn.edu!jeffe
>
>Somebody confirm this - this would be very nice to have.
>
>Do I understand correctly that Distill brings back a ps file containing well
>behaved primitives rather than a raster image?

The Distillery is a PostScript program, and as such, there is only one
version of it.  There is also a hack Mac program called something like
DistillPS whose only purpose is to prepend the distill code to the front
of a file on the Mac and to collect the resulting PS file.  If you have
a copy of DistillPS, there should be a file called "still.ps" in your
System Folder that will work just fine from a UNIX system.  In fact, it
was developed on a UNIX system.

Yes, the Distillery returns well-behaved primitives rather than a raster
image.  They actually aren't quite primitives, but simple procedures that
are a bit more efficient with time and space than the native operators.

Glenn Reid
glenn@heaven.woodside.ca.us
..{adobe,next}!heaven!glenn

woody@chinacat.Unicom.COM (Woody Baker @ Eagle Signal) (06/10/90)

In article <25789@netnews.upenn.edu>, jeffe@eniac.seas.upenn.edu (George J. Jefferson) writes:
> 
> This question gets asked alot. - but I havn't seen an answer yet.
> 
> c) its in the frequent questions thing and i'll never hear the end of it
> 
Lets start with the following:
First you have to know what encapulated postscript is.  The definitive
information for that can be obtained from the fileserver @ adobe.com
Once you have that document, then a simple text filter can be used to
wrap the minimum essential information around the data.  You will have
to print it out, then measure the bounding box to find the entry sizes
that EPS needs for the bounding box line.

Cheers
Woody

> 
> 
> 
> 
> 
> George Jefferson    jeffe@eniac.seas.upenn.edu   george@sol1.lrsm.upenn.edu