🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.ghostscript.bug
Article #55

eps2epsi won't work with GhostScript 2.4

#55
From: G.D.Pratt
Date: Mon, 06 Apr 1992 10:23
167 lines
5123 bytes
Hi,
Gisle Aas (Gisle.Aas@nr.no) posted a EPS --> EPSI filter a while back which
used GhostScript and perl to generate a "Preview" section. I find this
program _very_ useful for adding a Preview bitmap so that xfig can show EPS
files on screen.

This worked fine with 2.3 but now I'm ready to put up GhostScript 2.4 
it gives this error:-

 Can't run GhostScript at eps2epsi line 99, <> line 5405

and dumps core. This is on a SEQUENT SYMMETRY S81 (DYNIX(R) V3.1.2 NFS #6) 
running perl:-

 This is perl, version 4.0
 
 $RCSfile: perl.c,v $$Revision: 4.0.1.6 $$Date: 91/11/11 16:38:45 $
 Patch level: 19
 
I emailed Gisle but got no reply. Let me know if you want more information.
thanks,
gerry

-- 
gerry pratt  --  workstation support  --  university of keele
email:  gerry@seq1.keele.ac.uk  --------  tel:  (0782) 583072

#!/usr/local/bin/perl
# From: aas@boeygen.nr.no (Gisle Aas)
# Newsgroups: comp.lang.postscript
# Subject: Re: EPSF -> EPSI converter needed.
# Message-ID: <AAS.92Feb10183759@boeygen.nr.no>
# Date: 10 Feb 92 17:37:59 GMT
# Sender: news@ulrik.uio.no (Mr News)
# Reply-To: Gisle.Aas@nr.no
# Organization: Norwegian Computing Centre, Oslo, Norway
# Lines: 186
# 
# The EPSI files includes a bitmap preview of what gets painted by the
# PostScript program. This is a filter (you need perl && ghostscript):
# 
'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] =~ /^%!PS-Adobe-/);

# 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]
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);





###########################################################################
-- 
gerry pratt  --  workstation support  --  university of keele
email:  gerry@seq1.keele.ac.uk   *   telephone :  0782 583072
"these opinions are mine, mine, Mine.....ALL MINE I TELL YOU!"
Technical Details
Message-ID: <2471@keele.keele.ac.uk>
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!seq1.keele.ac.UK!gerry

Show Full Headers
Complete Article Headers
Newsgroups: gnu.ghostscript.bug
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!seq1.keele.ac.UK!gerry
From: gerry@seq1.keele.ac.UK (G.D.Pratt)
Subject: eps2epsi won't work with GhostScript 2.4
Message-ID: <2471@keele.keele.ac.uk>
Sender: gnulists@ai.mit.edu
Organization: University of Keele, England
Distribution: gnu
Date: Mon, 6 Apr 1992 10:23:13 GMT
Approved: bug-ghostscript@prep.ai.mit.edu
Lines: 168