pdf2mtiff 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #!/bin/bash
  2. # pdf2mtiff
  3. #
  4. # Rasterizes a PDF file, saving as a single multipage g4 compressed
  5. # tiff file
  6. #
  7. # input: PDF file
  8. # output file
  9. # output: ccitt-g4 compressed mulitipage tiff file
  10. #
  11. # Note 1: Requires ghostscript
  12. # Note 2: If you give it images with bpp > 1, the result will be ugly.
  13. # Note 3: A modern alternative to ghostcript is to use poplar:
  14. # If the pdf is composed of images that were orthographically generated:
  15. # pdftoppm -png <pdf-file> <pdf-root> [output in png]
  16. # If the pdf is composed of images that were scanned:
  17. # pdftoppm -jpeg <pdf-file> <pdf-root> [output in jpeg]
  18. scriptname=${0##*/}
  19. if test $# != 2
  20. then
  21. echo "usage: " $scriptname " pdfin tiffout"
  22. exit -1
  23. fi
  24. pdfin=$1
  25. tiffout=$2
  26. # assert (input pdf filename ends in .pdf)
  27. if test ${pdfin##*.} != pdf
  28. then
  29. echo $scriptname ": " $pdfin "does not end in .pdf"
  30. exit -1
  31. fi
  32. # 'echo "0 neg 0 neg" translate' is the mysterious "primer"
  33. rm /tmp/junkpdf*
  34. # --------- Choose one of the two options below ---------
  35. # output image size at 300 ppi
  36. #echo "0 neg 0 neg" translate | /usr/bin/gs -sDEVICE=tiffg4 -sOutputFile=/tmp/junkpdf%03d.tif -r300x300 -q - ${pdfin}
  37. #./writemtiff /tmp junkpdf ${tiffout}
  38. # output image size at 600 ppi
  39. echo "0 neg 0 neg" translate | /usr/bin/gs -sDEVICE=tiffg4 -sOutputFile=/tmp/junkpdf%03d.tif -r600x600 -q - ${pdfin}
  40. ./writemtiff /tmp junkpdf ${tiffout}
  41. # ------------------------------------------------------