File: pdf2png-binary

package info (click to toggle)
leptonlib 1.84.1-4
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie
  • size: 29,476 kB
  • sloc: ansic: 196,041; sh: 4,543; cpp: 2,026; makefile: 284
file content (38 lines) | stat: -rw-r--r-- 1,089 bytes parent folder | download | duplicates (3)
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
#!/bin/bash
#   pdf2png-binary
#
#     Rasterizes a PDF file, saving as a set of binary png images
#
#     input:  PDF
#             root name of output files
#     output: 1 bpp png files for each page
#
#  Note 1:  Requires ghostscript
#
#  Note 2:  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 " inpdffile outpngroot"
  exit -1
fi

inpdffile=$1
outpngroot=$2

# need mysterious "primer"
# choose one of the two options below

# output image size depending on resolution
echo "0 neg 0 neg" translate | gs -sDEVICE=pngmono -sOutputFile=${outpngroot}%03d.png -r300x300 -q - ${inpdffile}

# output fixed image size
#echo "0 neg 0 neg" translate | gs -sDEVICE=pngmono -sOutputFile=${outpngroot}%03d.png -g2550x3300 -r300x300 -q - ${inpdffile}