Thursday, September 15, 2011

Imagemagick - pdf, etc

A trail of crumbs about turning JPGs into printable PDFs. The key is "printable", because we can move jpgs into a pdf without any issues, but what does it take to print? Also in this post: converting PDF to JPG's (ImageMagick)

For example, suppose we have a simple two-page letter: we sign it and it's ready to mail so we scan it. We want to take the two jpgs, one for each page, and make it into a single 2-page pdf. This is trivial. Put them in a directory and
$ convert *.jpg somefilename.pdf
If this gives low quality or a too-large file, try the more recent version, which is compression specific, eg JPEG or PNG:
$ convert *.jpg -compress JPEG somefilename.pdf
We want this as close to copy quality, in case we have to print it later. Particularly so if we have a collection of handwritten notes from a class. Clarity is important.

scanning resolution

I typically don't scan at more than 75 lines, because that makes a clean copy for a jpg and it isn't unreasonably large.

merge pdf's into one

$ gs -q -sPAPERSIZE=letter -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=out.pdf a.pdf b.pdf
Using GhostScript, quality is maintained, unlike if "convert" from ImageMagick is used. ImageMagick is good for going from one file type, say jpg's, and converting to another, say pdf's. If you run it with pdf's as the input and output, quality is diminished. Other pdf merge programs are not typically installed with a distro, but can be added...eg, pdftk and pdfconcat.

PDF to JPG

I have a multiple page PDF and I want to break it out into individual. Sometimes I can get away with 75 lines, but it works much cleaner at 150:
$ convert -density 150 some.pdf %d.jpg
And out they come.

No comments: