11

I have a folder with 100 jpg images. I want to convert these images into a multi-page pdf file, with all the images (cropped to A4 size). They are already in the correct rotation.

Which tools should I use?

Anthon
  • 78,313
  • 42
  • 165
  • 222

3 Answers3

17

Requirements

ImageMagick

Type the follow line to commmand prompt for intall ImageMagick:

sudo apt-get install imagemagick

Convert from jpegs to PDF:

Go to the work directory (directory of jpegs):

cd work/directory/path

Convert the JPG files to PDF:

convert *.jpg foo.pdf

source : http://bitprison.net/jpg_to_pdf

Vishwanath Dalvi
  • 4,346
  • 5
  • 20
  • 17
8

Unfortunately convert changes the image before so to have minimal loss of quality, i.e. the quality of the original jpg, you need to use img2pdf, I use this commands:

A shorter one liner solution using only img2pdf

Make PDF

img2pdf *.jp* --output combined.pdf

Optionally add OCR to the output PDF

ocrmypdf combined.pdf combined_ocr.pdf

This was the original commands with more command and more tools needed:

  1. This to make a pdf file out of every jpg image without loss of either resolution or quality:

    ls -1 ./*jpg | xargs -L1 -I {} img2pdf {} -o {}.pdf

  2. This to concatenate the pdfpages into one:

    pdftk *.pdf cat output combined.pdf

  3. And last I add an OCRed text layer that doesn't change the quality of the scan in the pdfs so they can be searchable:

    pypdfocr combined.pdf

Eduard Florinescu
  • 11,153
  • 18
  • 57
  • 67
3

I highly recommend the Python CLI program img2pdf for lossless conversion:

https://gitlab.mister-muffin.de/josch/img2pdf

Example usage:

img2pdf img1.png img2.jpg -o out.pdf
Adam Erickson
  • 220
  • 2
  • 5