In this article, we will discuss - how to convert PNG, JPEG to PDF in Ubuntu 20.04 LTS release. We can do it through img2pdf command-line utility.
But, first we would discuss the installation steps required to get the command-line utility (i.e. img2pdf). Thereafter, its implementation and various options through relevant examples.
img2pdf can help us in lossless conversion of images to PDF.
Note: Following operations would require you to have superuser privileges. In case you don't have one, then contact your System Administrator for assistance.
Install img2pdf in Ubuntu 20.04 LTS release
We can get the command-line utility (i.e. img2pdf) through the package - img2pdf available in standard Ubuntu repository. Therefore, we need to first update the repository to make the latest version of package available. Hence, issue the following in terminal -
sudo apt update
Next, to install the package itself -
sudo apt install img2pdf
To verify the package version installed -
Convert PNG, JPEG to PDF in Ubuntu 20.04 LTS
Consider we have five images to try different img2pdf options. So, lets say we have -
A.png B.png C.png D.png E.png
It is worth mentioning here that, although we have gone ahead with the png format. We can apply the same operations on jpeg files as well.
Open a terminal and head to the directory where our images are stored. This can be done through cd command-line utility -
- Now, to convert all images to pdf in one-go
img2pdf <input_file> -o <output_pdf>For instance,
img2pdf *.png -o outcome.pdf
- Or, to convert only one image file to pdf -
img2pdf A.png -o outcome.pdf
- Specify the files to be converted to pdf -
img2pdf B.png D.png E.png -o outcome.pdf
In this case only B,png, D.png and E.png will be converted to outcome.pdf
- Up till now, you may have noticed that images are converted inline with their respective sizes. We can also specify page size as well -
img2pdf B.png D.png E.png --pagesize 18cmx12cm -o outcome.pdf
- Or, to specify image size -
img2pdf B.png D.png E.png --imgsize 18cmx12cm -o outcome.pdf
In conclusion, we have discussed how to convert PNG, JPEG to PDF in Ubuntu 20.04 LTS release.