Convert images such as PNG to PDF (Linux)
Firstly, ensure that ImageMagick is installed on your machine. You can verify its installation by executing the following command:
$ convert --v
Afterwards, certain modifications need to be made to the policy.xml file of ImageMagick to avoid issues in the conversion process. To achieve this, sudo privileges are required:
$ sudo nano /etc/ImageMagick-6/policy.xml
In this step, we utilize the nano text editor to view the contents of policy.xml. Alternatively, editors such as vim or emacs can also be employed. Proceed to locate the line:
<policy domain="coder" rights="none" pattern="PDF" />
Here, it is necessary to grant read and write permissions for PDF:
<policy domain="coder" rights="read|write" pattern="PDF" />
Now, for the conversion process, simply use:
$ convert image.png output.pdf
If there are multiple images to be converted into a single PDF, you can use the following command:
$ convert image1.jpg image2.jpg image3.jpg output.pdf
Join the conversation