[comp.sys.next] PS to EPS: HELP!

staggers@casbah.acns.nwu.edu (Ken Staggers) (02/26/91)

This is no doubt an FAQ, but no one I have spoken to really knows how
to do this well.  We have data flow diagrams that we need to bring to
the NeXT and WriteNow.  They are in *.ps format.  WriteNow wants *.eps.
We have tried grabbing it with scene (after displaying it with preview)
but the quality of it obviously poor.

I have a giftoeps program, scene allows tiff to eps, eps to tiff, but
WHERE IS ps to eps and eps to ps?  

If you know of a way or a program (a ps to tiff would be great also!)
PLEASE e-mail me ASAP..... THANKS A MILLION!

--Ken
  staggers@casbah.acns.nwu.edu

(I've never used the frame demo program, is that a possible solution?)

eps@toaster.SFSU.EDU (Eric P. Scott) (02/26/91)

In article <1991Feb26.021202.5712@casbah.acns.nwu.edu> staggers@casbah.acns.nwu.edu (Ken Staggers) writes:
>WHERE IS ps to eps and eps to ps?  

ps->eps isn't always possible.  You might be able to use Glenn
Reid's distillery, and something that computes bounding boxes.
Maybe.  This is a comp.lang.postscript question, not a
comp.sys.next question.

eps->ps is a null conversion; eps is effectively a subset of ps.

>If you know of a way or a program (a ps to tiff would be great also!)

TIFF is resolution-dependent.  What looks good on-screen will be
awful on a laser printer.

					-=EPS=- (the original)

orthlieb@adobe.COM (Carl Orthlieb) (02/27/91)

There is a PostScript program available on our mail server called 'epsfinfo'
that should do what you want.  You tack it onto the head of your PS file 
and then send it down to the PostScript interpreter.  You will then get
back the bounding box and font usage info for your PS file.  If you then
change the top of your file to read:
	%!PS-Adobe-3.0 EPSF-3.0
	%%BoundingBox: <llx> <lly> <urx> <ury>
	%%DocumentFonts: <font1> <font2> <font3> ...
you should then have an EPS file (w/o a preview). <llx>, <lly>, <urx>, and
<ury> are the bounding box values sent back by the epsfinfo program (make
sure that these are integer values). <font1>, <font2>, <font3>, etc.
are the names of the fonts used by your file (e.g. Times-Roman).

Note that there are some PS operators that should not be used in an
EPS file.  The epsfinfo program will notify you if your PS file uses
these operators.  See Appendix I of the new red book for more info.

Hope this helps, Carl 8-)

P.S. The file you want from the server is Programs/epsfinfo.ps

----------- Server Access Information -----------
The PS-File-Server is an automatic mail-response program. That means you
mail it a request, and it mails back the response. It is not accessible 
via anonymous FTP.

To get in touch with the server, send a message to the appropriate address,
either:
	uucp: {sun,decwrl}!adobe!ps-file-server OR
	internet: ps-file-server@adobe.COM
containing the word "help" in either the Subject: field or the message body.
It will reply with a message on how to use the available services.

There are many items available from the server; Documents (as PostScript
files), program sources, Adobe Font Metrics files, PostScript Printer
Description files, and other itmes.

You might send a separate message containing the word "index" to save some
time once you get the help message.

The file server does not respond to requests from users named "root",
"system", "daemon", or "mailer". This is to prevent mail loops from bounced
messages.

Note: If you do not receive help from the server within a day or so, it is
probably because the server's mail to you has bounced. You can try again
and use the "path" command within your message specifying a known return
path that the server should use. For example:
	path pyramid!rutgers!zakkaroo!jj
(substitute whatever address is appropriate)

If you have any problems contacting the server, or you have any suggestions,
please send a message to the moderator (ps-file-person@adobe.COM).

Carl 8-) 

new@ee.udel.edu (Darren New) (02/27/91)

In article <1991Feb26.110147.22371@agate.berkeley.edu> izumi@fugitive.berkeley.edu (Izumi Ohzawa) writes:
>Print the page out, use a ruler and measure the bounding box.

Or prepend the following postscript code to the file before printing it.

>If the above fails, get the EPS file specification from
>Adobe (send mail to ps-file-server@adobe.com with Subject: help,
>and another mail with Subject: index Documents).

Nothing I know of on the file server actually has the EPS specs. Rather,
the EPS documents say which comments are required for which functions
without saying what the semantics of the comments are.  For example,
they will say "Always have BoundingBox, have IncludeFile for included
files, ..."
                     -- Darren


%! 
% bb.ps --
% 
% Prints a file, but keeps track of bounding box info, and prints the box at
% the end (around the figure.)
% 

50 dict dup /$BoundingBox exch def begin

/xdef {
	exch def
} def

/xstore {
	exch store
} def

/bb-pt+ {
	exch
	4 -1 roll add
	3 1 roll add
} def

% 
% Stubs of old functions.
% 

/-stroke /stroke load def
/-fill /fill load def
/-eofill /eofill load def
/-image /image load def
/-show /show load def
/-awidthshow /awidthshow load def
/-showpage /showpage load def

% 
% New Functions.
% 

/stroke {
	gsave
	{
		flattenpath
	 	strokepath	% Make sure to take line width into account.
	} stopped {		% strokepath often hits a limitcheck.
		grestore	% Restore the original path
		gsave
	} if
	bb-path			% Accumulate it into our box.
	grestore

	-stroke
} def

/fill {
	gsave
	bb-path
	grestore

	-fill
} def

/eofill {
	gsave
	bb-path
	grestore

	-eofill
} def

% 
% Text is implemented by reducing everything to an `awidthshow'.
% 

/show {
	0 0 0 0 0		% Extra parameters for awidthshow
	6 -1 roll		% Bring the string back up
	awidthshow
} def

/widthshow {
	0 0			% Extra parameters for awidthshow
	3 -1 roll		% Bring the string back up.
	awidthshow
} def

/ashow {
	0 0 0 
	6 3 roll
	awidthshow
} def

/awidthshow {
	5 dict begin
	gsave
	currentpoint
	2 copy /@starty xdef /@startx xdef
	2 index stringwidth	% Get the natural length of the string
	bb-pt+			% Add to the start to get the end.

	2 index length		% How many characters?

	dup			% Add the offsets to each character
	6 index mul
	exch 5 index mul
	bb-pt+

	5 index 3 index
	bb-chcount		% How many padding characters?

	dup			% Add the offsets for each pad.
	9 index mul
	exch 8 index mul
	bb-pt+

	/@endy xdef /@endx xdef

	bb-fontheight		% Get the height and depth of the current font.
	
	4 copy
	@startx @starty bb-pt+ bb-point
	@startx @starty bb-pt+ bb-point
	@endx @endy bb-pt+ bb-point
	@endx @endy bb-pt+ bb-point

	newpath				% $Debug
	@startx @starty moveto		% $Debug
	@endx @endy lineto		% $Debug
	bb-bwstroke			% $Debug
	
	grestore
	end

	-awidthshow
} def

% 
% `image':
% 
% Assume here that the image lands in the unit square.
% 

/image {
	0 0 bb-point
	1 1 bb-point

	-image
} def

% 
% `showpage':
% 
% Just draw the box around the figure and print the page, and then initialize
% the bounding box variables again.
% 

/bb-string 10 string def

/showpage {
	initgraphics

	bb-llx bb-lly itransform 	% Convert them into default coords.
	bb-urx bb-ury itransform
	/bb-lly xstore /bb-urx xstore
	/bb-ury xstore /bb-llx xstore

	bb-llx bb-lly moveto		% Make the box
	bb-llx bb-ury lineto
	bb-urx bb-ury lineto
	bb-urx bb-lly lineto
	closepath

	bb-bwstroke			% Draw the box.

	0 setgray
	/Courier findfont 10 scalefont setfont
	bb-llx bb-lly 12 sub moveto
	bb-llx bb-string cvs -show ( ) -show
	bb-lly bb-string cvs -show ( ) -show
	bb-urx bb-string cvs -show ( ) -show
	bb-ury bb-string cvs -show

	bb-init
	-showpage
} def

% 
% BoundingBox functions:
% 
% We accumulate the information about the bounding box into four variables.
% The data is stored in device coordinates.
% 

/bb-init {
	/bb-llx 99999 store
	/bb-lly 99999 store
	/bb-urx -99999 store
	/bb-ury -99999 store
} def

/bb-llx 0 def
/bb-lly 0 def
/bb-urx 0 def
/bb-ury 0 def

% 
% x y `bb-point' -
% 
% Takes a point in user coordinates and adds it into the bounding box info.
% 

/bb-point {
	transform		% Convert to device coords.
	dup
	dup bb-lly lt {	
		/bb-lly xstore
	} {
		pop
	} ifelse
	dup bb-ury gt {
		/bb-ury xstore
	} {
		pop
	} ifelse

	dup
	dup bb-llx lt {
		/bb-llx xstore
	} {
		pop
	} ifelse
	dup bb-urx gt {
		/bb-urx xstore
	} {
		pop
	} ifelse
} def

% 
% - `bb-path' -
% 
% Incorporates the bounding box of the path into the bounding box info.
% 

/bb-path {
	gsave
	{
		0 setlinejoin
		flattenpath
	} stopped {
		grestore
		gsave
	} if
	pathbbox
	bb-point
	bb-point
	grestore
} def

% 
% A nice black-and white line drawing function.
% 

/bb-bwstroke {
	0 setlinewidth			% Thinnest possible lines
	1 setgray			% White first
	[5] 0 setdash			% Only half the line
	gsave -stroke grestore
	0 setgray			% Then black
	[5] 5 setdash			% On the other half
	-stroke
} def

% 
% Stuff for text.
% 

% 
% char-code string `bb-chcount' occurs
% 
% Counts the number of times a character appears in a string.
% 

/bb-chcount {
	0 exch
	{
		2 index eq {
			1 add
		} if
	} forall
	exch pop
} def

% 
% - `bb-fontheight' heightx heighty depthx depthy
% 
% Returns the offsets to the lowest point and highest point in the current
% font.
% 

/bb-fontheight {
	currentfont begin
	FontBBox
	exch pop 0 exch
	FontMatrix transform
	4 2 roll
	exch pop 0 exch
	FontMatrix transform
	end
} def

% Start it up.

bb-init

%  end of bb.ps
-- 
--- Darren New --- Grad Student --- CIS --- Univ. of Delaware ---
----- Network Protocols, Graphics, Programming Languages, 
      Formal Description Techniques (esp. Estelle), Coffee, Amigas -----
              =+=+=+ Let GROPE be an N-tuple where ... +=+=+=

eps@toaster.SFSU.EDU (Eric P. Scott) (02/27/91)

In article <45850@nigel.ee.udel.edu> new@ee.udel.edu (Darren New) writes:
>Nothing I know of on the file server actually has the EPS specs.

It should be in Documents as EPSF; this is a supplement to
PostScript Document Structuring Conventions.

There are several dozen PS operators that are poison to EPS.
Multipage PS documents need to be broken up.  It's just not
as simple as computing a BoundingBox.

					-=EPS=-