How to use GIMP or pdftoppm command line tools to convert PDF to image (PNG, JPEG)

This article explains how to convert pages of a PDF document into image files (PNG, JPEG, etc.). For this task we will use (you can choose the one you like):

  • GIMP (GNU Image Processing Program): For those who want to use, you can use a graphics application to accomplish this task. Since GIMP cannot automatically export all PDF pages by default (it needs to be exported page by page), this article also contains the GIMP plugin, which can export all layers as separate images.
  • pdftoppm: This command line tool is poppler / poppler-utils Package, and can convert PDF documents to images (each PDF page as a separate image), such as PNG, JPEG, etc. This tool can convert a single page, all pages or page range of a PDF document, and has multiple options such as specifying resolution, image cropping, etc.

GIMPIt is a free open source image editor for Linux, Windows and macOS, which can export PDF document pages to various image formats, including PDF, JPEG, TIFF, BMP, etc.
When opening a PDF document with GIMP, each page is added as a separate layer, and only one PDF page can be exported as an image at a time. You can use the GIMP plugin to export all PDF pages (GIMP layers) or a selected set of layers as separate images at once.

Use GIMP to convert one or several PDF pages to PNG, JPEG and other image formats.

Let’s start using GIMP to convert single (or only a few) PDF pages to PNG, JPEG, etc. without installing any plugins. From GIMP File Menu click Open And select the PDF file. One Import from PDF The dialog should pop up-make sure Open pages as Option set to Layers,then click Import:GIMP import dialog from PDF

In the GIMP Layer dialog box, scroll to the page you want to convert from PDF to PNG, JPEG, etc., and then drag it to the top with your mouse cursor to make it the first layer:GIMP layer

Next, click from the “GIMP File” menu Export As.... In the export dialog, you can change the exported file extension to the desired image format (in the Name Top) or click Select File Type (By Extension) At the bottom of the dialog, select the format of the PDF pages that will be used for export:

Now all you have to do is press Export The button saves PDF pages as PNG, JPEG, TIFF or other image formats.
Depending on the image type of the PDF page used for export, GIMP will display a dialog box through which you can change certain settings such as image quality, compression level, etc. Make any changes you want here and click Export The image file will be saved to your computer.
If you want to export other pages of the PDF document to an image, move the layer containing the page to the top of the layer list in the GIMP and repeat the process. To use GIMP to convert an entire PDF (or a large number of PDF pages at once) to JPEG, PNG, and other image formats, see the instructions below.

Use the GIMP Export Layer plugin to export all / selected layers (in this case PDF pages) as separate images.

Export layer Is a GIMP plugin that can export layers as separate images. It can export layers in any file format supported by GIMP, and has multiple options, such as exporting all layers, only visible layers, only selected layers, and so on.Download GIMP’s Export Layers plugin. You can easily install this plugin on Windows using the provided Windows installer. To install it on Linux or macOS, download the Export Layers ZIP archive, unzip and copy export_layers.py Files and export_layers Folder to:

  • Linux:
    • GIMP 2.8: ~/.gimp-2.8/plug-ins
    • GIMP 2.10 is installed using the package manager of the Linux distribution: ~/.config/GIMP/2.10/plug-ins
    • GIMP 2.10 installed from the Flathub Flatpak package: ~/.var/app/org.gimp.GIMP/config/GIMP/2.10/plug-ins
    • GIMP 2.10 installed using snap: ~/snap/gimp/current/.config/GIMP/2.10/plugins
  • Apple system:
    • GIMP 2.8: /Users/[your username]/Library/Application Support/GIMP/2.8/plug-ins
    • GIMP 2.10: /Users/[your username]/Library/Application Support/GIMP/2.10/plug-ins

If GIMP was running when the plugin was installed, restart it.
For more information on installing the Export Layers GIMP plugin, see. document.
Now use GIMP to open the PDF file and make sure Open pages as Option set to Layers In the import dialog, as described above.
Now you can convert all PDF pages or a selected set of pages to image formats like PNG, JPEG, and any other format supported by GIMP by: File -> Export Layers... From the GIMP menu. If you want to export all PDF pages as separate PNG images, just select the save location and press Export Button.
of Export Layers Dialog boxes let you change file extensions and perform other advanced operations. Click on png Fields at the bottom of the dialog box to change the image format:GIMP exports all layers as PNG images

For advanced options, click Settings at the bottom Export Layers Dialog and then Show more settings.
For example, if you only want to export the layers selected in the preview dialog (as shown on the right) Export Layers Dialog box), click + Add Constraint..., Then Only layers selected in the preview:GIMP export selected PDF layer as PNG

You can now click on the layer in the sidebar on the right to preview and hold Shift Key and click another layer to select all layers between them. Or hold Ctrl Key and click each layer you want to export.
Now all that’s left to do is click Export Button, GIMP will start exporting your selected PDF page (or all) to PNG, JPEG or any image format you choose:GIMP export layer as PNG image

For more information on custom exporting using Export Layers, visit Plugin documentation page.
You might also be interested: configure GIMP 2.10 to use Photoshop keyboard shortcuts (how-to)

Convert PDF to image (PNG, JPEG, etc.) from the command line using pdftoppm

pdftoppm can convert PDF document pages to PNG, JPEG and other image formats from the command line. You can convert all pages of a PDF document into individual PDF files, a single page or a page range. It supports specifying image resolution, scaling, cropping generated images, etc. pdftoppm is part of it. poppler / poppler-utils / poppler-tools Software package (depending on the Linux distribution you are using). Install this package as follows:

  • Debian, Ubuntu, Linux Mint, and other Debian / Ubuntu-based Linux distributions:
sudo apt install poppler-utils
  • Fedora:
sudo dnf install poppler-utils
  • openSUSE:
sudo zypper install poppler-tools
  • Arch Linux:
sudo pacman -S poppler

On other Linux distributions, use the package manager to install poppler / poppler-utils package.
Now let’s start converting the entire PDF using pdftoppm (we call it document.pdf In this example) change to PNG and name each page of the PDF converted to PNG as document-01.png, document-02.png and many more:

pdftoppm -png document.pdf document

Want to convert PDF pages to JPEG instead of PNG? use -jpeg instead. For TIFF, use -tiff. If you don’t specify an image format, pdftoppm converts PDF pages to PPM image files by default. To define the range of pages that convert PDF to image using pdftoppm, use -f N, Where N is the page number of the first page to be printed in this case, and -l NIn this case, N is the last page to be printed.
For example, convert 5 to 15 pages from a PDF document to document.pdf In the example) convert to PNG with pdftoppm and name each resulting image as document-05.png, document-06.png And so on, you would use:

pdftoppm -png -f 5 -l 15 document.pdf document

Do you want to increase the DPI of the converted image? By default, pdftoppm converts PDF pages into images with a DPI of 150. To increase DPI, add -rx with -ry To the command, as well as your custom value.
For example, to use a DPI of 300 for the resulting image, use:

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

To see all the options supported by pdftoppm, run pdftoppm --help with man pdftoppm.
You might like PDF-related articles:

  • How to use LibreOffice Writer to create fillable PDF forms
  • PDFArranger: Merge, Split, Rotate, Crop, or Rearrange PDF Documents (PDF-Shuffler Fork)

Source

Related Posts