DeveloperBreeze

How to Convert PDF to Image on Ubuntu

Converting a PDF to an image can be useful for sharing content on platforms that don't support PDF, or for extracting images from a PDF file. This tutorial will guide you through converting PDF files to image formats like PNG or JPEG on Ubuntu.

Requirements

To convert PDFs to images on Ubuntu, we’ll use a tool called pdftoppm, which is part of the poppler-utils package, and ImageMagick to provide more options if needed.

Step 1: Install poppler-utils

The pdftoppm tool is available via poppler-utils. To install it, open a terminal and run the following command:

sudo apt update
sudo apt install poppler-utils

Step 2: Convert PDF to Image

Once pdftoppm is installed, you can use it to convert a PDF to an image format like PNG or JPEG.

Syntax

pdftoppm [options] input.pdf output

For example, to convert the first page of a PDF to a PNG image, use the following command:

pdftoppm -png input.pdf output

This will convert all pages of the PDF into PNG images, and the images will be saved with names like output-1.png, output-2.png, etc.

If you want to convert specific pages, you can specify the page range using the -f (from page) and -l (last page) options:

pdftoppm -png -f 1 -l 1 input.pdf output

This command converts only the first page of the PDF into a PNG image.

Step 3: Convert PDF to JPEG

To convert the PDF to JPEG format, simply change the -png flag to -jpeg:

pdftoppm -jpeg input.pdf output

Again, all pages will be converted, and each page will be saved as output-1.jpg, output-2.jpg, etc.

Step 4: Install ImageMagick (Optional)

For more advanced conversion options, you can use ImageMagick, which is a powerful image processing tool.

Install it by running:

sudo apt install imagemagick

Once installed, you can use the convert command to convert PDFs to images:

convert -density 150 input.pdf output.png

Here, -density 150 sets the resolution of the output image, which can improve image quality. You can replace output.png with output.jpg for JPEG conversion.

Step 5: Handling Multi-Page PDFs

If you want to convert only specific pages of a PDF with convert, you can specify the page number:

convert -density 150 input.pdf[0] output.png

This command converts only the first page (0-indexed) of the PDF to an image. You can adjust the page number as needed.

Step 6: Batch Conversion (Optional)

If you have multiple PDF files to convert, you can use a simple loop to convert all PDFs in a directory to images:

for pdf in *.pdf; do
    pdftoppm -png "$pdf" "${pdf%.pdf}"
done

This script converts all PDF files in the current directory to PNG images.

Conclusion

You now know how to convert PDF files to image formats like PNG or JPEG using both pdftoppm and ImageMagick on Ubuntu. These tools provide flexibility, allowing you to convert single or multiple pages and adjust image quality as needed.

Summary of Key Commands:

  • Convert PDF to PNG:
  pdftoppm -png input.pdf output
  • Convert PDF to JPEG:
  pdftoppm -jpeg input.pdf output
  • Using ImageMagick:
  convert -density 150 input.pdf output.png

Related Posts

More content you might like

Tutorial

ما هو حقن التبعيات (Dependency Injection)؟

public function handle(Logger $logger) {
    $logger->log("Handling action...");
}

وتستخدم أقل، حيث يتم تعيين التبعية مباشرة في خاصية داخل الكائن.

Dec 01, 2025
Read More
Article

أفضل طرق إزالة الصدأ من العدّة والمسامير – دليل شامل منزلي واحترافي

  • تنظيف متساوٍ لجميع المسامير.
  • معالجة 200–300 مسمار في عملية واحدة.
  • لا حاجة لتوصيل كل مسمار على حدة.
  • مناسبة للكميات الصناعية الصغيرة.
  • ضع طبقة من المسامير داخل الطبق.
  • وصّل القطب السالب بالطبق.
  • ضع قطبًا موجبًا (قطعة حديد) في الجهة المقابلة داخل المحلول.

Dec 01, 2025
Read More
Tutorial

How to Stop SSH From Timing Out

Edit the SSH daemon config:

sudo nano /etc/ssh/sshd_config

Aug 21, 2025
Read More
Tutorial

How to Translate URLs in React (2025 Guide)

npm install react-router-dom i18next react-i18next i18next-browser-languagedetector
/src
  /locales
    en.json
    fr.json
  /pages
    Home.js
    About.js
  i18n.js
  App.js
  routes.js

May 04, 2025
Read More

Discussion 0

Please sign in to join the discussion.

No comments yet. Be the first to share your thoughts!