Install img2pdf on Ubuntu 22.04

Install img2pdf on Ubuntu 22.04

The img2pdf is a tool for converting images (JPEG, PNG, etc.) to PDF file via command line. This tool performs a lossless conversion. The images included in the PDF file has the same color information for each pixel like an original images.

This tutorial explains how to install img2pdf on Ubuntu 22.04.

Install img2pdf

Run the following command to update package lists:

sudo apt update

Next, install img2pdf:

sudo apt install -y img2pdf

When installation is finished, we can check version of img2pdf:

img2pdf --version

Testing img2pdf

Download images for testing:

wget -qO test1.png https://raw.githubusercontent.com/opencv/opencv/master/samples/data/sudoku.png
wget -qO test2.jpg https://raw.githubusercontent.com/opencv/opencv/master/samples/data/board.jpg

Run the img2pdf command to convert given images to PDF file. The -o option allows specifying the output file.

img2pdf test1.png test2.jpg -o test.pdf

It is possible to convert all images stored in the current directory to PDF file as follows:

img2pdf *.png *.jpg -o test.pdf

Uninstall img2pdf

If you decided to completely remove img2pdf and related dependencies, use the following command:

sudo apt purge --autoremove -y img2pdf

Leave a Comment

Cancel reply

Your email address will not be published.