-
Notifications
You must be signed in to change notification settings - Fork 791
Expand file tree
/
Copy pathmypstopnm
More file actions
executable file
·66 lines (56 loc) · 1.16 KB
/
mypstopnm
File metadata and controls
executable file
·66 lines (56 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/sh
#set -vx
USAGE="$0 [-r <resolution>] [-landscape] [psfile]"
res=72
outfile=-
#if [ $# = 0 ]; then
# echo $USAGE >&2; exit 1
#fi
while [ $# != 0 ]; do
case "$1" in
-l*)
landscape=true
shift;;
-r)
res=$2
shift 2;;
*)
if [ "$infile" = "" ]; then
infile="$1"
elif [ "$outfile" = "-" ]; then
outfile="$1"
else
echo $USAGE >&2; exit 1
fi
shift;;
esac
done
if [ -z "$infile" ]; then
infile=/tmp/mypstopnm$$
trap "rm $infile" 0
cat >$infile
fi
set -- `grep "%%BoundingBox" "$infile"`
comment="$1"
x1="$2"
y1="$3"
x2="$4"
y2="$5"
if [ "$comment" != "%%BoundingBox:" ]; then
echo "No BoundingBox found in EPS file" >&2; exit 2
fi
if [ "$landscape" = "true" ]; then
trans="270 rotate $x2 neg $y1 neg translate"
xsize=`expr \( $y2 - $y1 \) \* $res / 72`
ysize=`expr \( $x2 - $x1 \) \* $res / 72`
else
trans="$x1 neg $y1 neg translate"
xsize=`expr \( $x2 - $x1 \) \* $res / 72`
ysize=`expr \( $y2 - $y1 \) \* $res / 72`
fi
echo $trans | gs \
-sDEVICE=ppmraw \
-sOutputFile="$outfile" \
-r${res} \
-g${xsize}x${ysize} \
-dNOPAUSE -dQUIET -dSAFER -q - "$infile" -c showpage -c quit