Portable Document Format (PDF) files are widely used nowadays. Images in any format are still easier to edit and manipulate than PDF files so it is general practice to convert pdf files to images to edit them.

In this article, you will learn different ways to convert PDF files to images.

Prerequisites

  • Linux-based system
  • Terminal access
  • A user account with sudo privileges.

Note: The commands in this tutorial are executed on a Linux Mint system. All the methods in the tutorial are valid for any Linux-based system.

Convert PDF to Image Using the Command Line Interface(CLI)

Convert PDF to Image With Pdftoppm Tool

Pdftoppm command-line tool comes in the popper-utils package. To install and use pdftoppm, first install the popper-util package.

sudo apt-get install poppler-utils

How to Convert a PDF File to PNG/JPG Image in Linux centos Debian Desktop linux shell ubuntu

Following is the basic syntax of the pdftoppm command.

pdftoppm –

Note: The name of the PDF file used in this tutorial is sample.pdf. You need to insert your filename and image name in the above command.

pdftoppm -png sample.pdf sample

How to Convert a PDF File to PNG/JPG Image in Linux centos Debian Desktop linux shell ubuntu

Pdftoppm tool comes with various options. For example, you can target and convert specific pages in your pdf file with the following command.

pdftoppm -png -f 10 -l 15 sample.pdf Sample

-f and -l option specifies the first and last page number. In the output, you can see the converted images reflect the mentioned range.

How to Convert a PDF File to PNG/JPG Image in Linux centos Debian Desktop linux shell ubuntu

You can also customize the quality of your converted image with pdftoppm. To customize quality, use -rx and -ry options to change the width and height resolutions.

pdftoppm -png -rx 300 -ry 300 sample.pdf sample

How to Convert a PDF File to PNG/JPG Image in Linux centos Debian Desktop linux shell ubuntu

To learn more about the pdftoppm tool and its options, run the following command and read detailed information.

pdftoppm --help

Or

man pdftoppm

Convert PDF to Image With Imagemagick Tool

Imagemagick is another utility that offers image manipulation functions. It also has programming APIs which makes it highly convenient for use.

You can install the Imagemagick utility with the following command.

sudo apt install imagemagick

How to Convert a PDF File to PNG/JPG Image in Linux centos Debian Desktop linux shell ubuntu

Once it is installed, You can convert your pdf files to images with the following command.

convert sample.pdf output_image.jpg

How to Convert a PDF File to PNG/JPG Image in Linux centos Debian Desktop linux shell ubuntu

You can see that PDF file conversions are not authorized by policy. If you get this output, go to the Imagemagick policy XML file with the following command.

sudo nano /etc/ImageMagick-6/policy.xml

You will see the following code snippet at the end of the file.










Comment it out in the following format.

How to Convert a PDF File to PNG/JPG Image in Linux centos Debian Desktop linux shell ubuntu

Press Ctrl O and Ctrl X to finish editing. Run the following command to convert the PDF.

convert sample.pdf output_image.jpg

How to Convert a PDF File to PNG/JPG Image in Linux centos Debian Desktop linux shell ubuntu

As you see, the conversion is successful now.

You can refine images by using the -density and -quality options.

convert -density 300 sample.pdf -quality 100 output_image.jpeg

How to Convert a PDF File to PNG/JPG Image in Linux centos Debian Desktop linux shell ubuntu

Convert PDF to Image Using the Graphical User Interface(GUI)

Convert PDF to Image With GIMP Application

GNU Image Manipulation Program (GIMP) is an image manipulation software.

To install GIMP, search and install it from the Software Manager.

How to Convert a PDF File to PNG/JPG Image in Linux centos Debian Desktop linux shell ubuntu

Navigate and import the PDF file and go to the page you want to convert into an image.

How to Convert a PDF File to PNG/JPG Image in Linux centos Debian Desktop linux shell ubuntu

How to Convert a PDF File to PNG/JPG Image in Linux centos Debian Desktop linux shell ubuntu

Then export it as desired image format.

How to Convert a PDF File to PNG/JPG Image in Linux centos Debian Desktop linux shell ubuntu

How to Convert a PDF File to PNG/JPG Image in Linux centos Debian Desktop linux shell ubuntu

Conclusion

In this article, you have learned various ways to convert your PDF files to image format.