pdf2tiff 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #!/bin/bash
  2. # pdf2tiff
  3. #
  4. # Rasterizes a PDF file, saving as a set of g4 compressed tiff images
  5. #
  6. # input: PDF
  7. # root name of output files
  8. # output: g4 compressed tiff binary files for each page
  9. #
  10. # Note 1: Requires ghostscript
  11. #
  12. # Note 2: A modern alternative to ghostcript is to use poplar:
  13. # If the pdf is composed of images that were orthographically generated:
  14. # pdftoppm -png <pdf-file> <pdf-root> [output in png]
  15. # If the pdf is composed of images that were scanned:
  16. # pdftoppm -jpeg <pdf-file> <pdf-root> [output in jpeg]
  17. scriptname=${0##*/}
  18. if test $# != 2
  19. then
  20. echo "usage: " $scriptname " inpdffile outtifroot"
  21. exit -1
  22. fi
  23. inpdffile=$1
  24. outtifroot=$2
  25. # strip off directory and suffix parts of $1 to use in other names
  26. basename=${1##*/}
  27. baseroot=${basename%.*}
  28. # make names for temporary files
  29. tmppdffile=${baseroot}.$$_.pdf
  30. tmppdfroot=${tmppdffile%.*}
  31. # have the temporary files deleted on exit, interrupt, etc:
  32. trap "/bin/rm -f ${tmppdfroot}*" EXIT SIGHUP SIGINT SIGTERM
  33. cp $inpdffile $tmppdffile
  34. # need mysterious "primer"
  35. #echo "0 neg 0 neg" translate | gs -sDEVICE=tiffg4 -sOutputFile=${outtifroot}%03d.tif -r300x300 -q - ${tmppdffile}
  36. echo "0 neg 0 neg" translate | gs -sDEVICE=tiffg4 -sOutputFile=${outtifroot}%03d.tif -g2550x3300 -r300x300 -q - ${tmppdffile}
  37. #tiffcp -c g4 ${tmppsfile%.*}*.tif $outtiffile