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
|
#!/bin/bash
# pdf2mtiff
#
# Rasterizes a PDF file, saving as a single multipage g4 compressed
# tiff file
#
# input: PDF file
# output file
# output: ccitt-g4 compressed mulitipage tiff file
#
# Note 1: Requires ghostscript
# Note 2: If you give it images with bpp > 1, the result will be ugly.
# Note 3: A modern alternative to ghostcript is to use poplar:
# If the pdf is composed of images that were orthographically generated:
# pdftoppm -png <pdf-file> <pdf-root> [output in png]
# If the pdf is composed of images that were scanned:
# pdftoppm -jpeg <pdf-file> <pdf-root> [output in jpeg]
scriptname=${0##*/}
if test $# != 2
then
echo "usage: " $scriptname " pdfin tiffout"
exit -1
fi
pdfin=$1
tiffout=$2
# assert (input pdf filename ends in .pdf)
if test ${pdfin##*.} != pdf
then
echo $scriptname ": " $pdfin "does not end in .pdf"
exit -1
fi
# 'echo "0 neg 0 neg" translate' is the mysterious "primer"
rm /tmp/junkpdf*
# --------- Choose one of the two options below ---------
# output image size at 300 ppi
#echo "0 neg 0 neg" translate | /usr/bin/gs -sDEVICE=tiffg4 -sOutputFile=/tmp/junkpdf%03d.tif -r300x300 -q - ${pdfin}
#./writemtiff /tmp junkpdf ${tiffout}
# output image size at 600 ppi
echo "0 neg 0 neg" translate | /usr/bin/gs -sDEVICE=tiffg4 -sOutputFile=/tmp/junkpdf%03d.tif -r600x600 -q - ${pdfin}
./writemtiff /tmp junkpdf ${tiffout}
# ------------------------------------------------------
|