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?
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?
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
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:
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
This to concatenate the pdfpages into one:
pdftk *.pdf cat output combined.pdf
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
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