ps2png 936 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #!/bin/bash
  2. # ps2png
  3. #
  4. # Rasterizes a postscript file, saving as a set of bitmaps
  5. #
  6. # input: PostScript file
  7. # root name of output files
  8. # output: png binary files for each page
  9. #
  10. # Restriction: the input PostScript file must be binary
  11. #
  12. # N.B. Requires ghostscript
  13. scriptname=${0##*/}
  14. if test $# != 2
  15. then
  16. echo "usage: " $scriptname " inpsfile outpngroot"
  17. exit -1
  18. fi
  19. inpsfile=$1
  20. outpngroot=$2
  21. # strip off directory and suffix parts of $1 to use in other names
  22. basename=${1##*/}
  23. baseroot=${basename%.*}
  24. # make names for temporary files
  25. tmppsfile=${baseroot}.$$_.ps
  26. tmppsroot=${tmppsfile%.*}
  27. # have the temporary files deleted on exit, interrupt, etc:
  28. trap "/bin/rm -f ${tmppsroot}*" EXIT SIGHUP SIGINT SIGTERM
  29. cp $inpsfile $tmppsfile
  30. # need mysterious "primer"
  31. echo "0 neg 0 neg" translate | gs -sDEVICE=pngmono -sOutputFile=${outpngroot}%03d.png -g2550x3300 -r300x300 -q - ${tmppsfile}