Wednesday, December 10, 2014

Converting PDF to a series of images... and back...

Books:

1. gather all images into one directory
2. edit / crop using GIMP
3. in GIMP, export as *.mng file

4. convert to pdf:
convert -interlace none -density 300 -quality 100 infile.mng outfile.pdf

---


...or PNGs...

convert -quality 100 input.pdf output-%04d.png

for really high quality (ie for TV slides):
convert -interlace none -density 300 -quality 80 -resize 1200 infile.pdf outfile_%03d.jpg

to convert images to pdf:

convert *.png output.pdf

-- pdf may be too large; use smallpdf.com to compress:

http://smallpdf.com/compress-pdf

Three other linux-based options to compress PDFs:

gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -dNOPAUSE -dQUIET -dBATCH -sOutputFile=outfile.pdf infile.pdf

- slightly higher quality, slightly larger size
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook -dNOPAUSE -dQUIET -dBATCH -sOutputFile=outfile.pdf infile.pdf

- much more precise, much slower, not much smaller...
gs -q -dNOPAUSE -dBATCH -dSAFER -sDEVICE=pdfwrite -dCompatibilityLevel=1.3 -dPDFSETTINGS=/screen -dEmbedAllFonts=true -dSubsetFonts=true -dColorImageDownsampleType=/Bicubic -dColorImageResolution=72 -dGrayImageDownsampleType=/Bicubic -dGrayImageResolution=72 -dMonoImageDownsampleType=/Bicubic -dMonoImageResolution=72 -sOutputFile=outfile.pdf infile.pdf