Friday, May 22, 2026Today's Paper

Omni Apps

How to Convert PDF to JPG in Ubuntu: The Ultimate CLI & GUI Guide
May 21, 2026 · 13 min read

How to Convert PDF to JPG in Ubuntu: The Ultimate CLI & GUI Guide

Discover how to convert PDF to JPG on Ubuntu using pdftoppm, ImageMagick (with policy fixes), GUI tools, and Python. Learn to convert JPG to PDF too!

May 21, 2026 · 13 min read
UbuntuLinux Command LinePDF Manipulation

Converting document formats is one of those daily administrative tasks that should be simple, but on Linux, it often requires knowing the exact utility and syntax. If you need to convert pdf to jpg in ubuntu, you have several robust options at your disposal. Whether you are looking for a lightning-fast terminal command, a bulk processing script, or a simple graphical interface (GUI), Ubuntu has native and open-source tools to handle the job.

In this comprehensive guide, we will walk through the absolute best ways to perform these conversions. We will cover the fastest command-line utilities, troubleshoot common security policy blockades, show you how to do the reverse process to convert jpg to pdf in ubuntu, and provide GUI alternatives for users who prefer mouse-clicks over shell prompts.


1. The Fastest Terminal Method: Using pdftoppm

If you want the quickest, most efficient, and pre-installed tool to ubuntu convert pdf to jpg, look no further than pdftoppm. Part of the poppler-utils package, pdftoppm is specifically engineered to render PDF pages into popular image formats like JPEG, PNG, and TIFF.

Unlike heavier image-manipulation suites, pdftoppm reads PDF files natively and processes them incredibly fast without consuming excessive system memory.

Verifying or Installing poppler-utils

On almost all standard Ubuntu desktop installations, poppler-utils is installed by default. However, if you are working on a minimal server or a lightweight container, you can install it using the Advanced Package Tool (APT):

sudo apt update
sudo apt install poppler-utils

Basic Command Syntax

To convert a PDF file into a series of JPEG images (one image per page), run the following command in your terminal:

pdftoppm -jpeg input.pdf output_page
  • input.pdf: The path to the PDF document you want to convert.
  • output_page: The prefix for the generated JPEG files. If your PDF has 3 pages, this command will output output_page-1.jpg, output_page-2.jpg, and output_page-3.jpg in your current working directory.

Controlling Resolution and Quality

By default, pdftoppm renders images at 150 DPI (dots per inch). For high-quality printing or archiving, you might want to increase this to 300 DPI. For quick draft sharing, 100 DPI is often sufficient. You can control the resolution using the -r flag:

pdftoppm -jpeg -r 300 input.pdf output_page

To optimize the physical output quality, you can also pass the -jpegopt flag to adjust compression quality (scale from 0 to 100):

pdftoppm -jpeg -jpegopt quality=90 -r 200 input.pdf output_page

Converting a Specific Page Range

If you are dealing with a 100-page document but only need page 5 through page 7 converted to JPG, use the -f (first page) and -l (last page) flags:

pdftoppm -jpeg -f 5 -l 7 input.pdf page_extract

This will output only page_extract-05.jpg, page_extract-06.jpg, and page_extract-07.jpg.


2. The Heavy-Duty Method: ImageMagick (And Fixing the Security Policy Error)

ImageMagick is the Swiss Army knife of image manipulation on Linux. It is incredibly powerful and supports hundreds of file formats. Many tutorials suggest using its famous convert command to convert pdf to jpg ubuntu:

convert -density 150 input.pdf output.jpg

However, if you run this on a modern version of Ubuntu (such as Ubuntu 20.04 LTS, 22.04 LTS, 24.04 LTS, or newer), you are highly likely to hit a frustrating wall. Your terminal will spit out a generic error resembling:

convert: attempt to perform an operation not allowed by the security policy 'PDF' @ error/constitute.c/IsCoderAuthorized/421.

Why Does This Error Happen?

This error is not a bug; it is a security feature. PDFs can contain complex vector graphics and embedded PostScript operations. Historically, security vulnerabilities in Ghostscript (the background interpreter ImageMagick uses to parse PDFs) allowed malicious actors to execute arbitrary code via poisoned PDF files. To protect users, Ubuntu package maintainers disable PDF reading and writing permissions in ImageMagick's system-wide configuration by default.

Step-by-Step Guide to Safely Fixing the Security Policy

If you trust the sources of the PDFs you are converting, you can edit the ImageMagick policy file to restore PDF conversion functionality.

Step 1: Open the ImageMagick policy.xml file in your terminal with administrative privileges. On most Ubuntu systems, the configuration is stored in the /etc/ImageMagick-6/ or /etc/ImageMagick-7/ directory:

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

(If you are on a newer distribution using ImageMagick 7, replace ImageMagick-6 with ImageMagick-7).

Step 2: Scroll down to the bottom of the file using your arrow keys and locate the XML line regulating PDF processing. It will look like this:

<policy domain="coder" rights="none" pattern="PDF" />

Step 3: Edit this line to change the rights from "none" to "read|write". The updated tag should look like this:

<policy domain="coder" rights="read|write" pattern="PDF" />

If you want a safer configuration that only allows ImageMagick to read PDFs (to convert them to JPGs) but prevents it from saving files as PDFs, use rights="read" instead:

<policy domain="coder" rights="read" pattern="PDF" />

Step 4: Save and exit the text editor. In nano, press Ctrl + O to write the changes, press Enter to confirm, and then Ctrl + X to exit the program.

Running the ImageMagick Conversion

Once you have modified the security file, you can successfully run the conversion. Use the -density parameter before loading the input PDF to ensure high rasterization quality:

convert -density 300 input.pdf -quality 90 output-%d.jpg
  • -density 300: Renders the PDF at a crisp 300 DPI.
  • -quality 90: Uses a high JPEG quality compression standard.
  • output-%d.jpg: The %d placeholder automatically numbers the output files sequentially (starting from page 0), producing files like output-0.jpg, output-1.jpg, etc.

3. Going the Other Way: Convert JPG to PDF in Ubuntu

Sometimes, you need to execute the reverse workflow: combining multiple digital camera images, scans, or screenshots into a single, cohesive PDF document. This section details how to ubuntu convert jpg to pdf cleanly and without loss of image quality.

Method A: The Fast, Lossless Way with img2pdf

Most image processing programs (including ImageMagick) unpack the JPEG pixel data and re-encode it when writing a PDF. This process takes a significant amount of CPU time and can introduce compression artifacts, which unnecessarily inflates the file size.

img2pdf is a specialized Python-based tool that avoids this entirely. It takes the raw JPEG data and embeds it directly into a PDF container without any recompression. The result is instant speed, pixel-perfect preservation, and highly optimized file sizes.

1. Install img2pdf:

sudo apt install img2pdf

2. Convert a single JPG image to a PDF page:

img2pdf image.jpg -o document.pdf

3. Combine multiple JPG images into a single multi-page PDF:

img2pdf page1.jpg page2.jpg page3.jpg -o finished_document.pdf

4. Batch convert all JPGs in a folder sorted alphabetically:

img2pdf *.jpg -o combined_album.pdf

Method B: Using ImageMagick for JPG to PDF

If you already adjusted your ImageMagick security policies in the previous section, you can use the versatile convert command to compile JPG images. Unlike PDF read actions, writing to a PDF is usually safe, but keeping ImageMagick's global PDF permissions enabled makes it incredibly straightforward:

convert page1.jpg page2.jpg page3.jpg output.pdf

To combine all .jpg files in the current folder, run:

convert *.jpg merged_portfolio.pdf

If the files are too large or you want to compress them inside the PDF, use the -compress flag:

convert -compress jpeg -quality 85 *.jpg optimized.pdf

4. Simple GUI Methods for Non-Terminal Users

While terminal commands are highly efficient, Linux is all about choices. If you prefer to visualize what you are working on, or need to verify pages visually before hitting "convert", Ubuntu supports excellent Graphical User Interfaces.

Option 1: LibreOffice Draw (Pre-Installed)

LibreOffice is Ubuntu's default office productivity suite. LibreOffice Draw is a surprisingly powerful vector editor that can open, edit, and export PDF pages.

  1. Launch LibreOffice Draw from your system's application menu.
  2. Go to File -> Open and select your target PDF document.
  3. Select the page you want to export from the thumbnail panel on the left.
  4. Go to File -> Export....
  5. In the file selection dialog, click the drop-down menu for File Format and choose JPEG (.jpg;.jpeg).
  6. Click Save. A small dialog will pop up, allowing you to fine-tune the output resolution (width, height) and JPEG compression quality.

Option 2: GIMP (GNU Image Manipulation Program)

If you are doing graphic design or need specialized image editing, GIMP is an exceptional open-source tool.

  1. Install GIMP if you do not have it: sudo apt install gimp
  2. Launch GIMP and go to File -> Open.
  3. Select your PDF. A prompt will appear asking you how to import the pages. You can import them as separate images or as individual layers in a single document.
  4. Once the pages are loaded, go to the page you want to export.
  5. Select File -> Export As....
  6. Name your file with a .jpg extension (e.g., page_one.jpg). GIMP will detect the target format dynamically.
  7. Click Export, adjust quality parameters, and save.

Option 3: Document Viewer (Evince)

Ubuntu's default PDF reading software, Document Viewer, has a simple workaround for converting PDF pages to images using the print driver:

  1. Double-click your PDF to open it in Document Viewer.
  2. Press Ctrl + P to open the Print dialog.
  3. Select Print to File under the list of printers.
  4. In the Output format options, change the format from PDF to PostScript or image format if supported by your setup, or print to a virtual image writer.

Note: Using pdftoppm remains vastly superior for output quality and ease of use compared to Document Viewer print workarounds.


5. Automation: Bulk Conversion Scripts

If you work as a system administrator or web developer, you will frequently need to automate file format pipelines. Here are two automation scripts to process bulk PDF directories.

Bash Loop for Converting Directories of PDFs

This shell script processes every PDF file in your directory and creates a dedicated sub-folder for its resulting JPEG images. This keeps your folders clean and structured.

Create a script file named convert_all.sh:

#!/bin/bash

# Loop through all PDF files in the current folder
for pdf_file in *.pdf; do
    # Check if files actually exist to avoid running on empty lists
    [ -e "$pdf_file" ] || continue
    
    # Extract file name without extension
    filename=$(basename "$pdf_file" .pdf)
    
    echo "Processing: $pdf_file..."
    
    # Create a destination directory for the converted pages
    mkdir -p "$filename-images"
    
    # Convert PDF to JPG inside the custom directory
    pdftoppm -jpeg -r 150 "$pdf_file" "$filename-images/$filename"
done

echo "All PDF documents successfully rasterized to JPG!"

Give it execution permissions and run it:

chmod +x convert_all.sh
./convert_all.sh

Python Script Using the pdf2image Library

For integration into wider web backend or data processing pipelines, Python offers a clean wrapper around Poppler called pdf2image.

First, install the library:

pip install pdf2image

(Ensure poppler-utils is installed on your Ubuntu system, as the library relies on it background-side).

Create a script named convert.py:

import os
from pdf2image import convert_from_path

def convert_pdf_to_jpg(pdf_path, output_dir):
    # Create output path if it doesn't exist
    if not os.path.exists(output_dir):
        os.makedirs(output_dir)
        
    print(f"Converting {pdf_path}...")
    
    # Convert PDF pages to list of PIL image objects
    pages = convert_from_path(pdf_path, dpi=200)
    
    for i, page in enumerate(pages):
        image_name = f"page_{i+1}.jpg"
        image_path = os.path.join(output_dir, image_name)
        
        # Save image with JPEG compression quality
        page.save(image_path, 'JPEG', quality=85)
        print(f"Saved: {image_path}")

if __name__ == "__main__":
    # Adjust the input file and output destination paths accordingly
    convert_pdf_to_jpg("sample_document.pdf", "my_converted_jpgs")

Run the script:

python3 convert.py

Comparison of PDF to JPG Conversion Tools

Tool Best Used For Pros Cons
pdftoppm General fast rendering Pre-installed, exceptionally fast, lightweight CLI-only
ImageMagick Heavy graphical workflows High customization, filters, bulk control Blocked by default security policies
img2pdf Image to PDF conversion Lossless, super fast, tiny file output sizes Does not convert PDF to JPG (only vice-versa)
LibreOffice Draw Visual manual inspection Easy-to-use GUI, pre-installed Slower for multiple pages or documents
GIMP Advanced graphical tweaking Fine-grained color and format controls Heavy app, manual page-by-page exports

Frequently Asked Questions (FAQ)

Why are my converted JPG images blurry?

This usually happens because the default rendering resolution is too low. If you use pdftoppm without specifying flags, or if you run convert without setting the -density flag, they process images at 150 DPI or lower. To fix this, always specify higher DPI settings in your terminal. Use pdftoppm -jpeg -r 300 or convert -density 300 for crisp, printable outputs.

How do I extract embedded images from a PDF rather than rendering the page?

If you want the raw images (like diagrams, photographs, or logos) that are embedded inside the pages of a PDF, rendering the whole page to a JPG is not the best route. Instead, use pdfimages from the poppler-utils package:

pdfimages -jpeg document.pdf /destination/prefix

This extracts all the actual raw JPEGs stored inside the PDF directly without re-rendering or modifying them.

How can I convert a password-protected PDF file to JPG?

If your PDF file is encrypted or requires a user password, both pdftoppm and pdfimages let you pass the password arguments in your command:

pdftoppm -jpeg -upw "your_password_here" input_protected.pdf output_prefix

Replace "your_password_here" with the document password.

Is it safe to convert private PDFs using online conversion websites?

If your PDF files contain sensitive materials—like financial reports, tax records, identification cards, or private credentials—you should never upload them to free, third-party online PDF-to-JPG conversion sites. These sites process your files on external servers and may retain copies. Using native Ubuntu command-line utilities ensures your data never leaves your secure local system.

Why does ImageMagick generate massive file sizes when I convert JPG to PDF?

ImageMagick decompresses standard JPEG files and recompresses them when wrapping them inside a PDF container. To prevent this duplication and compile them losslessly at their exact initial file size, use img2pdf instead:

img2pdf input.jpg -o output.pdf

Conclusion

Whether you need to convert an administrative form to an image or compile your creative design work into a single archive, Ubuntu offers incredibly versatile utilities to process your graphics. For daily administrative jobs, we highly recommend utilizing pdftoppm to convert pdf to jpg ubuntu due to its incredible rendering speeds and default safety settings. When you need to go the other way around and convert jpg to pdf ubuntu, the img2pdf tool is the unbeatable champion for lossless, lightweight formatting.

With these toolsets and command sequences saved in your developer toolbelt, you are fully equipped to build automated document pipelines or quickly export pages directly from your desktop. Keep this guide bookmarked for the next time you need to manage PDF conversions in your Linux environment!

Related articles
Lottery Wheels for Pick 5: The Ultimate Guide to Free Systems
Lottery Wheels for Pick 5: The Ultimate Guide to Free Systems
Master lottery wheels for pick 5 to boost your odds. Learn how abbreviated wheels, key number systems, and free pick 3 lottery wheels maximize your wins.
May 21, 2026 · 17 min read
Read →
Name Randomizer for Raffle: How to Pick Fair Winners Every Time
Name Randomizer for Raffle: How to Pick Fair Winners Every Time
Need a reliable name randomizer for raffle drawings? Learn how to pick fair winners using online tools, Excel, Google Sheets, and custom scripts.
May 21, 2026 · 13 min read
Read →
How to Convert PDF to Image in Linux: The Ultimate CLI Guide
How to Convert PDF to Image in Linux: The Ultimate CLI Guide
Master the best ways to convert PDF to image in Linux. Learn how to use pdftoppm, fix ImageMagick security errors, and convert images back to PDF easily.
May 21, 2026 · 11 min read
Read →
Water Intake by Weight kg: Your Daily Hydration Guide
Water Intake by Weight kg: Your Daily Hydration Guide
How much water should you drink? Calculate your daily water intake by weight kg with our scientific formulas, custom charts, and expert tips.
May 21, 2026 · 14 min read
Read →
Cite My YouTube Video MLA: The Ultimate 9th Edition Guide
Cite My YouTube Video MLA: The Ultimate 9th Edition Guide
Wondering how to cite my youtube video mla style? Learn the official MLA 9 rules, view clear step-by-step examples, and use generator tools safely.
May 21, 2026 · 11 min read
Read →
The Facebook Number Generator Guide: Get Verified Safely
The Facebook Number Generator Guide: Get Verified Safely
Want to bypass SMS verification without giving away your privacy? Discover how to safely use a Facebook number generator to secure your account.
May 21, 2026 · 12 min read
Read →
QuillBot Grammar Changer: How to Fix, Rewrite & Expand Text
QuillBot Grammar Changer: How to Fix, Rewrite & Expand Text
Want flawless, natural writing? Learn how to master the QuillBot grammar changer, sentence changer, and expander tools to transform your prose instantly.
May 21, 2026 · 13 min read
Read →
Tax Return Estimate 2026: Calculate Your Refund with New Laws
Tax Return Estimate 2026: Calculate Your Refund with New Laws
Want to project your refund or what you owe? Get a precise tax return estimate 2026 using the latest OBBBA tax brackets, standard deductions, and rules.
May 21, 2026 · 15 min read
Read →
How to Make Your iPhone Save JPG Not HEIC: A Complete Guide
How to Make Your iPhone Save JPG Not HEIC: A Complete Guide
Frustrated with .HEIC files? Learn how to make your iPhone save photos as JPG, convert existing images, and transfer compatible files to your PC or Mac.
May 21, 2026 · 13 min read
Read →
Online JPG to PNG Editor: The Ultimate Image Optimization Guide
Online JPG to PNG Editor: The Ultimate Image Optimization Guide
Looking for an online jpg to png editor that does more than convert? Learn how to edit, remove backgrounds, and optimize your images in seconds.
May 21, 2026 · 11 min read
Read →
Related articles
Related articles