Posted by CANbike on Sat, 6 Jun 2015

[Linux] Convert a Folder of Images to a Single PDF File

Converting a folder of images to a single PDF document is easy with the Imagemagick convert command.

convert *.jpg document.pdf

results in all .jpg files in the present directory being converted into a single PDF file.

Resolution

The PDF document may appear blurry as a result of the default resolution of 72 dots per inch (DPI). This can be improved by specifying the density option.

convert -density 150 *.jpg document.pdf

will convert all .jpg files into a single PDF file at a resolution of 150 dpi.

File Size

The resulting PDF file size may be greater than the sum of the images.

Use the quality option to specify the compression ratio for a smaller file size.

convert -quality 50 -density 150 *.jpg document.pdf

Black and White Images

To further reduce the file size, change the color space to grayscale for black and white images (i.e. text document scans) by specifying the type option.

convert -type Grayscale -quality 50 -density 150 *.jpg document.pdf

Not Just Images

The convert command is versatile and can process a number of image formats and other PDF documents. In other words, input can contain various image formats and other PDF files too.

Convert Images to Single PDF Document.png


Related Item(s):