In this tutorial, we will show you how to convert PDF files to image on Linux. Sometimes we need quickly convert a PDF file into images or save a set of images as a PDF file. To do this, we can use a couple of command-line tools such as poppler-utils and ImageMagick.
This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘
sudo‘ to the commands to get root privileges. I will show you through the step-by-step convert PDF files to image on Linux.
Convert Pdf File To Image on Linux
Method 1. Convert PDF file via ImageMagick.
First, install ImageMagick on the Linux system. The installation of ImageMagick on the Ubuntu system is a rather simple process. From your terminal window execute the following command:
sudo apt install imagemagick
Use the command given below to convert all the images into pdf file:
convert my-file.pdf output_image.png
Note: if you’re facing that PDF file conversions are not authorized by policy. You can fix it by executing the following command:
sed -i '/disable ghostscript format types/,+6d' /etc/ImageMagick-6/policy.xml
Method 2. Convert PDF file via Pdftoppm.
First, install Pdftoppm on the Linux system. To install
poppler-utils, we need to execute the following command below:
sudo apt install poppler-utils
Following is the basic syntax of the pdftoppm command:
pdftoppm -jpeg sample.pdf output_file
pdftoppm convert-PDF-to-images.pdf convert-PDF-to-images-png
To see all the choices available and supported in pdftoppm, run the commands:
Congratulations! You have successfully converted the PDF file to an image. For more information about the convert PDF file to an image in Linux.