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.
- 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.
- Resolution of output images, I had to play with this a bit to get the exact numbers, depends on your input file too.
- The name of the input file.
Anyway, so you run that and suprise suprise you get alot of images, ripe for viewing 🙂 Enjoy.
Wow! That is what i needed! Thak you VERY much!
-sOutputFile=m_%d.pngnot too good with
Haha true, I’ll fix that. Thanks 🙂
Thanks for this article. You solved my Problem in no time!
(But it took me quite a time to discover this article)
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?
Check out the options for anti-aliasing etc here:
-dAlignToPixels might help.
It might sound basic but I can’t find gs.exe, I will appreciate any pointer to the executable.
Grab Ghostscript for windows:
It should be in there.
for windows its gswin32c instead of gs, and you will also need to add it to systemwnviroment variables.
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.
Thank you very much!!!
Saved my day.
thanks for this