File: ps2image

package info (click to toggle)
hyperlatex 2.9a-3
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 668 kB
  • ctags: 391
  • sloc: lisp: 2,680; sh: 199; makefile: 84; awk: 21
file content (54 lines) | stat: -rwxr-xr-x 1,077 bytes parent folder | download | duplicates (2)
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
#! /bin/sh
# convert ps file to Gif
#
resolution=95
quantcmd="cat"
transcmd="-transparent #ffffff "
antialiasing=""
#
usage() {
  echo "Usage:" 1>&2
  echo "  ps2image [ -res RESOLUTION ] [ -notrans ] psfile.ps file.png" 1>&2
  echo "  ps2image [ -res RESOLUTION ] [ -notrans ] psfile.ps file.gif" 1>&2
  echo " " 1>&2
  exit 1
}

[ $# -lt 2 ] && usage

while [ $# -gt 0 ]; do
  case $1 in
    -quant)
      quantcmd="ppmquant 50"
      ;;
    -notrans)
      transcmd=""
      ;;
    -antialiasing)
      antialiasing="-dTextAlphaBits=4 -dGraphicsAlphaBits=4"
      ;;
    -res)
      shift
      if [ $# -eq 0 ]; then
        echo "ps2image: no resolution specified" 1>&2
        exit 1
      fi
      resolution=$1
      ;;
    -*)
      usage;;
    *.ps)
      fig=$1;;
    *.png)
      image=$1; convertcommand="pnmtopng";;
    *.gif)
      image=$1; convertcommand="ppmtogif";;
  esac
  shift
done

cat $fig \
| gs -q -dNOPAUSE -r$resolution $antialiasing -sDEVICE=ppm -sOutputFile=- - \
| pnmcrop | $quantcmd | $convertcommand -interlace $transcmd > $image

echo "Done"