I think we all have been in the situation before, you have some scanned documents in JPG or PNG format that you need to convert into a PDF file.
There are many solutions for this on the internet, including free sites that just does it for you if you upload your images, but they almost always put some kind of watermark on the pages if you don’t pay them.
There are also a bunch of Windows applications that do this, but they are often complicated or full of ads.
This guide show you a free solution on Linux, that just works, is fast, and does not add any crap to the PDF.
To do this, you don’t need much. only 2 programs that can be installed with your package manager easily!
I am using Arch Linux on my laptop, but it should be the same on any other Linux system except the installation command for the 2 programs you need might be a little different.
First you have to install the software you need to make the magic happen. for this you need 2 applications called “ghostscript” and “imagemagick”.
Below are the commands needed to install it on Arch Linux and Debian/ubuntu Linux. If you know the installation command to other Linux distributions please leave a comment so i can add them.
NOTE: It is really important that ghostscript is installed first, else imagemagick will not know where it is located doing compilation.
Install it on Arch Linux with the following command:
pacman -S ghostscript imagemagick
Install it on Debian/ubuntu Linux with the following command:
apt-get install ghostscript imagemagick
Convert the images to PDF
When you have installed the 2 applications, then you are ready to convert your files.
You then have to make sure your images are in the right order. Page1 has to be called 1.png or 1.jpg depending on your filetype. Page2 has to be called 2.png or 2.jpg and so on….
If you don’t have the images in the right order with numbers, the pages will be mixed randomly when generating the PDF.
The command for this is the same in every distro.
convert *.png outputfile.pdf
Above you see the command to convert your images, in this example I am converting all .PNG files in the current folder to outputfile.pdf
If you need to do it for all .JPG files, the command would be:
convert *.jpg outputfile.pdf
You can change the name of the pdf to whatever you want just by changing the name in the command.
There you go, no ads, free, fast and simple!