Wednesday, May 09, 2007

Converting jpg files to pdf

Utilities for most conversions are fairly obvious in linux - ps2ps, ps2pdf, ps2eps, etc.

However converting jpg to pdf is not obvious, because it uses the command 'convert' that comes along with imagemagick (which is a display tool invoked by the command 'display')

Thus for converting a file x.jpg to x.pdf, run
$ convert x.jpg x.pdf

To do this in an automated fashion for all files in bash, type
$ for FILE in *.jpg; do convert "${FILE}" "${FILE/.jpg/.pdf}"; done