I\'m trying to convert a PDF to a PNG image (at least the cover of one). I\'m successfully extracting the first page of the PDF with pdftk. I\'m using imagemagick to do the
Couldn't get the accepted answer to work. Then found out that actually the solution is much simpler anyway as Ghostscript not just natively supports PNG but even multiple different "encodings":
png256png16pnggraypngmonoThe shell command that works for me is:
gs -dNOPAUSE -q -sDEVICE=pnggray -r500 -dBATCH -dFirstPage=2 -dLastPage=2 -sOutputFile=test.png test.pdf
It will save page 2 of test.pdf to test.png using the pnggray encoding and 500 DPI.