PDF To Image

I wanted to view a PDF on my PSP, but unfortunately the PDF was full of images so the usual viewer bookr didn’t want to load it. Luckily I managed to figure out how to convert the PDF into JPEGs so I could view them. Since I hadn’t found a guide in my searches, here is a rough guide of how I did it.
The Tool of choice for this exercise is ghostscript, in particular the command line component ‘gs’. Ghostscript is a PDF/PS interpreter, available on linux and windows (SF.net Download). The magical command line I used was:

gs -sDEVICE=jpeg -dJPEGQ=95 -dGraphicsAlphaBits=4 -dTextAlphaBits=4 -dDOINTERPOLATE -sOutputFile=m_%d.jpg -dSAFER -dBATCH -dNOPAUSE -r57x58 M.pdf
What does this all do?

  • sDEVICE=jpeg -dJPEGQ=95
    • Defines the image output format, there are alot of image types that can be saved, I chose JPEG as the PSP cannot view PNG images in the built in image viewer.
    • The list of available outputs can be found by running gs with no command line arguments, or by visiting http://www.cs.wisc.edu/~ghost/doc/cvs/Devices.htm
  • -dGraphicsAlphaBits=4 -dTextAlphaBits=4 -dDOINTERPOLATE
    • Antialiasing settings, these make your output look the best. Use them.
  • -sOutputFile=m_%d.png
    • The output file name, %d implies you want to split images by page, the %d will be replaced with the page number.
  • -dSAFER -dBATCH -dNOPAUSE
    • Batch processing options, makes gs output all of the images without stopping and confirming.
  • -r57x58
    • Resolution of output images, I had to play with this a bit to get the exact numbers, depends on your input file too.
  • M.pdf
    • The name of the input file.

Anyway, so you run that and suprise suprise you get alot of images, ripe for viewing 🙂 Enjoy.

12 thoughts on “PDF To Image

  1. Matze

    Hi.
    Thanks for this article. You solved my Problem in no time!
    (But it took me quite a time to discover this article)

  2. Luis

    Just what I was looking. However the quality is very poor, I can’t read the text that was on my original PDF, any suggestions on what to check to improve the output quality?

  3. Murat

    Hi,
    It might sound basic but I can’t find gs.exe, I will appreciate any pointer to the executable.
    Thanks.

  4. Steve

    Thanks for saving me several hours. Something I found necessary for some PDFs was -dUseCropBox, as some files will convert to .jpeg with incorrect margins, depending on their internal settings.

Comments are closed.