source: other-projects/trunk/mac-binaries/intel/ghostscript/bin/ps2epsi@ 17625

Last change on this file since 17625 was 17625, checked in by max, 16 years ago

Adding GhostScript 8.63 for Intel Mac and changing the location of ImageMagick 6.4.4 for Intel Mac that can process JPEG2000 files by default.

File size: 2.3 KB
Line 
1#!/bin/sh
2# $Id: ps2epsi 8491 2008-01-18 06:17:02Z alexcher $
3
4# This definition is changed on install to match the
5# executable name set in the makefile
6GS_EXECUTABLE=gs
7gs="`dirname $0`/$GS_EXECUTABLE"
8if test ! -x "$gs"; then
9 gs="$GS_EXECUTABLE"
10fi
11GS_EXECUTABLE=gs
12
13# try to create a temporary file securely
14if test -z "$TMPDIR"; then
15 TMPDIR=/tmp
16fi
17if which mktemp >/dev/null 2>/dev/null; then
18 tmpfile="`mktemp $TMPDIR/ps2epsi.XXXXXX`"
19else
20 tmpdir=$TMPDIR/ps2epsi.$$
21 (umask 077 && mkdir "$tmpdir")
22 if test ! -d "$tmpdir"; then
23 echo "failed: could not create temporary file"
24 exit 1
25 fi
26 tmpfile="$tmpdir"/ps2epsi$$
27fi
28trap "rm -rf \"$tmpfile\"" 0 1 2 3 7 13 15
29
30export outfile
31
32if [ $# -lt 1 -o $# -gt 2 ]; then
33 echo "Usage: `basename $0` file.ps [file.epsi]" 1>&2
34 exit 1
35fi
36
37infile=$1;
38
39if [ $# -eq 1 ]
40then
41 case "${infile}" in
42 *.ps) base=`basename "${infile}" .ps` ;;
43 *.cps) base=`basename "${infile}" .cps` ;;
44 *.eps) base=`basename "${infile}" .eps` ;;
45 *.epsf) base=`basename "${infile}" .epsf` ;;
46 *) base=`basename "${infile}"` ;;
47 esac
48 outfile=${base}.epsi
49else
50 outfile=$2
51fi
52
53ls -l "${infile}" |
54awk 'F==1 {
55 cd="%%CreationDate: " $6 " " $7 " " $8;
56 t="%%Title: " $9;
57 f="%%For:" U " " $3;
58 c="%%Creator: Ghostscript ps2epsi from " $9;
59 next;
60 }
61 /^%!/ {next;}
62 /^%%Title:/ {t=$0; next;}
63 /^%%Creator:/ {c=$0; next;}
64 /^%%CreationDate:/ {cd=$0; next;}
65 /^%%For:/ {f=$0; next;}
66 !/^%/ {
67 print "/ps2edict 30 dict def";
68 print "ps2edict begin";
69 print "/epsititle (" t "\\n) def";
70 print "/epsicreator (" c "\\n) def";
71 print "/epsicrdt (" cd "\\n) def";
72 print "/epsifor (" f "\\n) def";
73 print "end";
74 exit(0);
75 }
76 ' U="$USERNAME$LOGNAME" F=1 - F=2 "${infile}" >"$tmpfile"
77
78"$GS_EXECUTABLE" -q -dNOPAUSE -dSAFER -dDELAYSAFER -r72 -sDEVICE=bit -sOutputFile=/dev/null "$tmpfile" ps2epsi.ps "$tmpfile" <"${infile}" 1>&2
79rm -f "$tmpfile"
80rm -rf "$tmpdir"
81
82(
83cat << BEGINEPS
84save countdictstack mark newpath /showpage {} def /setpagedevice /pop load def
85%%EndProlog
86%%Page 1 1
87BEGINEPS
88
89cat "${infile}" |
90LC_ALL=C \
91sed -e '/^%%BeginPreview:/,/^%%EndPreview[^!-\~]*$/d' -e '/^%!PS-Adobe/d'\
92 -e '/^%%[A-Za-z][A-Za-z]*[^!-\~]*$/d' -e '/^%%[A-Za-z][A-Za-z]*: /d'
93
94cat << ENDEPS
95%%Trailer
96cleartomark countdictstack exch sub { end } repeat restore
97%%EOF
98ENDEPS
99
100) >> "${outfile}"
101
102exit 0
Note: See TracBrowser for help on using the repository browser.