We are going to explain how we can convert images in JPG format to PDF in an easy way. If you intend to perform the reverse action, you may also be interested in the command line program called pdfimages to dump the images contained in a PDF to JPEG format. But what we are looking for in this article is just the opposite, going from JPG to PDF with a simple tool as we will be able to see. By the way, there are also websites to carry out this type of conversion completely online and for free …
To carry out this type of conversion, we need to install the imagemagick package or the gscan2pdf package on our favorite distro , depending on whether we want the command line method or the graphic method. The installation is quite simple, you just have to use the package management tools used by the distribution you are using and install the package by name as we have indicated here, and once installed, we now move on to the steps you must follow to be able to transform one or several JPG images into PDF.
Convert JPG to PDF from command line:
If you have opted for the command line option and have installed the imagemagick package, in that case, once installed, we can have access to a series of command line tools and quite practical options. We are going to use the convert command to perform the conversion. The truth is that it has a multitude of options, so I recommend that you review the manual.
But the most basic thing, which is what we are looking for with this tutorial, would be to perform the conversion from the directory where the image or images are located. For example, imagine that we want to transform all the images from the / home directory to PDF or just one. For this you can use the first or the second of the following commands:
convert *.jpg my_file.pdf
convert my_image.jpg my_file.pdf
In the first, all the JPEG images are passed to the PDF at once, and in the second, only a specific one that coincides with that name. You can also use compression with the + compress, -rotate option to rotate the image the degrees you specify as a parameter, etc. For example, you can rotate the image 90 degrees and add compression with the following command:
convert -rotate 90 foto.jpg +compress nombre.pdf
But if yours are not the commands, then you can go to the next section …
JPEG to PDF conversion using a graphical interface:
Assuming that we already have the gscan2pdf program, we will see that the procedure is quite simple. The steps are:
- We open gscan2pdf.
- We add the images or select the directory where the images that we want to convert are located.
- Once added, we can reorder them by dragging them from the main screen of the application, from the list of images that appears just to the left.
- Once put in order we can click on the Save button to save.
- Now a screen will appear where we can choose many options, including changing the PDF metadata, adding a name, date, type, author, source, etc. Although it is not necessary to fill them if we do not need it. What is important is to select All if we want to convert all the images as PDF pages and in the output format choose the PDF format, since it supports other formats …
- We accept and the PDF will be generated with our images.
I hope it has helped you, for more suggestions or questions, do not forget to leave your comments …