🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.lang.postscript
3 messages
3 total messages Started by Kirby Files Mon, 31 Aug 1992 16:03
EPSI?
#2040
Author: Kirby Files
Date: Mon, 31 Aug 1992 16:03
18 lines
1406 bytes
I have a variation on an FAQ.  How can one generate an EPSI format
file?  I can transform a PS file to EPS no problem, that's trivial.
But does anyone out there know where I can get my hands on a spec for
EPSI, which apparently has some for of text encoded bitmap preview,
and does anyone have any ideas for generating that preview. Perhaps
using Ghostscript to generate a bitmap, and then somehow properly
encoding that bitmap in correct EPSI format?

I'm using FrameMaker on a Sun, and it's really particular about
importing PS; it will only accept EPSI.  Any other ideas on getting
FM to accept a PS file as graphic, and not text would be appreciated.

Thanks,
------
+   0__, ---     Kirby Files, 623-1673   | "Whoso would be a man     +
      /   ------ 29 Banks Street         | must be a nonconformist"
      |\   --    Somerville, MA  02144   | 
+ ---**-**------ files1@husc.harvard.edu | Ralph Waldo Emerson       +
Re: EPSI?
#2044
Author: Jon White
Date: Mon, 31 Aug 1992 18:58
195 lines
6086 bytes
In article <KFILES.92Aug31110335@virtual8.harvard.edu>, kfiles@virtual8.harvard.edu (Kirby Files) writes:
|> I have a variation on an FAQ.  How can one generate an EPSI format
|> file?  I can transform a PS file to EPS no problem, that's trivial.
|> But does anyone out there know where I can get my hands on a spec for
|> EPSI, which apparently has some for of text encoded bitmap preview,
|> and does anyone have any ideas for generating that preview. Perhaps
|> using Ghostscript to generate a bitmap, and then somehow properly
|> encoding that bitmap in correct EPSI format?
|>
|> I'm using FrameMaker on a Sun, and it's really particular about
|> importing PS; it will only accept EPSI.  Any other ideas on getting
|> FM to accept a PS file as graphic, and not text would be appreciated.

Here's a perl script for generating EPSI files from EPS files:

--cut here--
#!/usr/local/bin/perl
'di';
'ig00';

# EPSI file generator. Written by Gisle Aas, NR, 1991
# Converts all types of EPS-files to the EPSI format where a bitmap preview
# is included. You need GhostScript to render the bitmaps for you.

# $Log: eps2epsi,v $
# Revision 1.1  1991/05/28  09:18:04  aas
# Initial revision
#

$prog_name = substr($0,rindex($0,"/")+1);
require 'getopts.pl';
unless (&Getopts('w:')) {
  print STDOUT "Usage: $prog_name [-w <preview width>] [<file>]\n";
  exit 1;
}

die 'To many files' if ($#ARGV > 0);

@epsfile = <>;                  # slurp
die 'Not PostScript file' unless ($epsfile[0] =~ /^%!/);

# Get the dimensions of the picture
for (@epsfile) {
   ($llx, $lly, $urx, $ury) =
       /^%%BoundingBox:\s*(-?\d+)\s+(-?\d+)\s+(-?\d+)\s+(-?\d+)/;
   last if defined($llx);
}
die 'No %%BoundingBox found in file' unless defined($llx);

# Calculate 
$preview_width = int(($opt_w || 79) / 2) * 8;
$width  = $urx - $llx + 1;
$height = $ury - $lly + 1;
$scalefactor = $preview_width / $width;
$width  = int($width * $scalefactor);
$height = int($height * $scalefactor);

# Produce GhostScript program
$gsfile = "/tmp/gs$$.tmp";
open(GSFILE, ">$gsfile") || die "Can't write to file $gsfile";
print GSFILE <<"---EndGhostScriptProgram---";
%!GhostScript
/BITIMAGE_WIDTH $width def
/BITIMAGE_HEIGHT $height def
/BITIMAGE_FILE (%stdout) def

%---- Setup a memory device --------
[1 0 0 -1 0 BITIMAGE_HEIGHT]
BITIMAGE_WIDTH BITIMAGE_HEIGHT
%
% [1 1 1 rgbcolor 0 0 0 rgbcolor] <-- 2.3 arguments
% <ff 00>                         <-- 2.4 arguments from ghost@aladdin.com
%
<ff 00> 
makeimagedevice
setdevice

%--- Some transformations
/showpage {} def
$scalefactor dup scale
$llx neg $lly neg translate

%--- The old EPS file
@epsfile

%---- Print bitmap on a file -------
/line BITIMAGE_WIDTH 8 idiv 1 add string def
/output BITIMAGE_FILE (w) file def
output (---------) writestring
output 10 write
0  1  BITIMAGE_HEIGHT 1 sub { %for
   output (%) writestring
   currentdevice exch
   line copyscanlines
   output exch writehexstring
   output 10 write
} for
output flushfile
quit
---EndGhostScriptProgram---

close GSFILE;
close STDIN;    # so that GhostScript can't read it.

@gsoutput = `gs -q -DNODISPLAY $gsfile`;   # run GhostScript
die "Can't run GhostScript" unless $? == 0;
unlink $gsfile;

@preview = grep(/^-----/ .. 1, @gsoutput);   # remove GhostScript garbage
shift(preview);
if ($#preview < 0) {
  print STDERR "GhostScript gives no output for the specified file\n";
  print STDERR @gsoutput;
  exit 1;
}

print shift(epsfile);
$_ = shift(epsfile);
while (/^%%/) {
  if (/^%%BoundingBox:/) {
    print "%%BoundingBox: $llx $lly $urx $ury\n" if !defined($boundingbox);
    $boundingbox = 1;
  } elsif (/^%%EndComments/) {
    last;
  } else {
    print;
  }
  $_ = shift(epsfile);
}
print "%%BoundingBox: $llx $lly $urx $ury\n" if !defined($boundingbox);
print "%%EndComments
%%BeginPreview: $width $height 1 $height\n";
print @preview;
print "%%EndPreview\n";

print grep(!(/^%%BeginPreview:/ .. /^%%EndPreview/) && !/^%%BoundingBox:/,
           @epsfile);





###########################################################################
        # These next few lines are legal in both Perl and nroff.

.00;                    # finish .ig
 
'di                     \" finish diversion--previous line must be blank
.nr nl 0-1              \" fake up transition to first page again
.nr % 0                 \" start at page 1
';<<'.ex'; #__END__ #### From here on it's a standard manual page #########
.TH EPS2EPSI 1 "May 1991"
.SH NAME
eps2epsi \- Filter for inclusion of a preview in an EPS file
.SH SYNOPSIS
.B eps2epsi
[
.B \-w
.I preview_width
] [
.I filename
]
.SH DESCRIPTION
.B Eps2epsi
puts a preview section in a PostScript file (preferably EPSF).
The preview produced
is in the encapsulated PostScript interchange format (EPSI)
suitable for import by FrameMaker and other document composing
systems.
.B Eps2epsi
reads the file specified (or standard input) and sends the new file
with the preview included to standard output.
.PP
.B Esp2epsi
uses
.B GhostScript
to render the preview bitmap, which means that
.B GhostScript
must be installed at your system before you can use
.B eps2epsi.
.SH OPTIONS
.TP 5
.BI \-w " n"
Set the width (in characters) of the preview section. This also specifies the
resolution of the preview as
.I n
times 4 horizontally.
.SH SEE ALSO
.BR perl (1),
.BR gs(1)
.SH AUTHOR
Gisle Aas, Norwegian Computing Center (NR), Oslo, Norway.
<Gisle.Aas@nr.no>
.ex
Re: EPSI?
#2056
Author: Bill Lee
Date: Wed, 02 Sep 1992 02:16
38 lines
2173 bytes
In article <KFILES.92Aug31110335@virtual8.harvard.edu> kfiles@virtual8.harvard.edu (Kirby Files) writes:
>I have a variation on an FAQ.  How can one generate an EPSI format
>file?  I can transform a PS file to EPS no problem, that's trivial.
>But does anyone out there know where I can get my hands on a spec for
>EPSI, which apparently has some for of text encoded bitmap preview,
>and does anyone have any ideas for generating that preview. Perhaps
>using Ghostscript to generate a bitmap, and then somehow properly
>encoding that bitmap in correct EPSI format?

The spec for the EPSI format is in the Red Book. If you have the second edition,
it is on pages 730-732.

>
>I'm using FrameMaker on a Sun, and it's really particular about
>importing PS; it will only accept EPSI.  Any other ideas on getting
>FM to accept a PS file as graphic, and not text would be appreciated.
>
Actually, FrameMaker will accept EPS files without the preview image provided
in the EPSI format. The graphic will not be displayed since F.M. does not
interpret PostScript. The graphic area where the EPS file will be displayed
will be imaged as a light gray box (i.e., the bounding box of the EPS
image). The EPS file will be rendered properly when the F.M document is sent
to the printer (or other PS interpreter).

If you want F.M to actually display something when importing the EPS file,
you will have to get the preview image (which was the original question you
asked above).
>Thanks,
>------
>+   0__, ---     Kirby Files, 623-1673   | "Whoso would be a man     +
>      /   ------ 29 Banks Street         | must be a nonconformist"
>      |\   --    Somerville, MA  02144   | 
>+ ---**-**------ files1@husc.harvard.edu | Ralph Waldo Emerson       +


Regards,

Bill Lee
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads