How to Convert PDF to JPG on Linux Using the Command Line
Converting PDF pages to JPG images is a common need on Linux — for creating thumbnails, embedding pages in web content, extracting specific pages for sharing on image-based platforms, building slide decks from PDFs, or simply when you need an image format instead of a PDF. Linux offers three excellent command-line tools for this conversion: pdftoppm (fastest and highest quality), Ghostscript (most control, widely available), and ImageMagick's convert (most flexible for image processing pipelines). Each has its strengths, and knowing which to use in which situation saves time and produces better results. This guide provides practical, ready-to-use commands for all three tools, covers important options like DPI control and output quality, shows how to convert specific pages or all pages from a PDF, and explains how to integrate PDF-to-JPG conversion into shell scripts and automation pipelines. For quick, one-off conversions where you prefer a visual interface, LazyPDF's PDF to JPG tool in Firefox or Chromium is a fast alternative. But for high-volume processing, custom DPI requirements, or integration into larger workflows, the command-line tools covered here are the right choice.
Convert PDF to JPG on Linux Using pdftoppm (Recommended)
pdftoppm is the fastest and highest-quality option for PDF to image conversion on Linux. It's part of poppler-utils and produces excellent output with simple commands.
- 1Install poppler-utils: `sudo apt install poppler-utils` (Ubuntu/Debian) or `sudo dnf install poppler-utils` (Fedora).
- 2Convert all pages to JPG: `pdftoppm -jpeg document.pdf output_prefix` — creates output_prefix-1.jpg, output_prefix-2.jpg, etc.
- 3Convert at high resolution (300 DPI for print quality): `pdftoppm -jpeg -r 300 document.pdf page`
- 4Convert a specific page range (pages 3-7): `pdftoppm -jpeg -f 3 -l 7 document.pdf pages`
- 5Control JPEG quality (0-100): `pdftoppm -jpeg -jpegopt quality=85 document.pdf output`
Convert PDF to JPG on Linux Using Ghostscript
Ghostscript is already installed on most Linux systems and can convert PDFs to JPEG with fine control over quality settings. The conversion is slightly slower than pdftoppm but gives you more options for color management and output quality. The basic JPEG conversion command: `gs -dBATCH -dNOPAUSE -q -sDEVICE=jpeg -r150 -sOutputFile=page_%04d.jpg input.pdf` The `-r150` flag sets 150 DPI resolution, suitable for screen viewing. Use `-r300` for print-quality output. The `%04d` in the output filename creates zero-padded numbers (page_0001.jpg, page_0002.jpg) which sort correctly in file managers. For converting a single page, add `-dFirstPage=N -dLastPage=N`: `gs -dBATCH -dNOPAUSE -q -sDEVICE=jpeg -r150 -dFirstPage=5 -dLastPage=5 -sOutputFile=page_5.jpg input.pdf` Ghostscript also supports PNG output (use `-sDEVICE=png16m`) for transparency support, which is useful when PDF pages have transparent backgrounds.
Convert PDF to JPG on Linux Using ImageMagick
ImageMagick's `convert` command is extremely flexible and integrates naturally into image processing pipelines. For PDF to JPG conversion, it uses Ghostscript internally, but wraps it in ImageMagick's powerful image manipulation capabilities. Install ImageMagick: `sudo apt install imagemagick` Basic conversion: `convert -density 150 input.pdf output.jpg` Note: ImageMagick may have PDF processing disabled for security reasons in some distributions. If you get a 'not authorized' error, edit `/etc/ImageMagick-6/policy.xml` and change the PDF line from `none` to `read|write`. The power of ImageMagick comes from chaining operations. Convert a PDF to JPG while also resizing and watermarking: ``` convert -density 150 input.pdf \ -resize 1200x1600 \ -quality 85 \ output.jpg ``` Or convert to thumbnails: `convert -density 72 input.pdf -resize 200x200 -format jpg thumb_%04d.jpg` For batch operations that also process the images (crop, resize, adjust colors), ImageMagick is the most capable tool in the Linux PDF-to-image pipeline.
Choosing the Right DPI for PDF to JPG Conversion on Linux
DPI (dots per inch) is the most important quality setting when converting PDF to JPG on Linux. Choosing the right DPI for your use case prevents both over-sized files and insufficient image quality. 72 DPI — Screen thumbnails and previews only. Not suitable for reading text or viewing images at full size. Good for web thumbnail generation. 96–120 DPI — Web display at standard screen resolution. Adequate for images that will be viewed on monitors but not printed. 150 DPI — Good general-purpose setting for web content, email attachments, and presentations. This is the best starting point for most use cases — files are reasonably sized and quality is good for screen viewing. 200–300 DPI — Print-quality output. Use when the resulting JPG needs to be printed or reproduced at full size. Files are significantly larger but necessary for professional print applications. 600 DPI — High-quality scans and archival purposes. Files are very large — a single A4 page at 600 DPI can be 5–15MB as JPG. Use only when maximum fidelity is required. For most Linux workflow needs, 150 DPI in pdftoppm with quality 85 is the sweet spot: `pdftoppm -jpeg -r 150 -jpegopt quality=85 input.pdf output`.
Frequently Asked Questions
Which tool gives the best quality for PDF to JPG on Linux?
pdftoppm from poppler-utils generally produces the best quality output and is the fastest. It renders PDF pages natively without going through PostScript interpretation, which Ghostscript does. For most use cases, pdftoppm at 150-300 DPI produces excellent JPG output.
How do I convert only one page of a PDF to JPG on Linux?
With pdftoppm: `pdftoppm -jpeg -f 5 -l 5 input.pdf page` converts only page 5. With Ghostscript: add `-dFirstPage=5 -dLastPage=5` to the command. With ImageMagick: use `convert input.pdf[4] output.jpg` (zero-indexed, so page 5 is index 4).
Can I convert a PDF to PNG instead of JPG on Linux?
Yes. With pdftoppm, replace `-jpeg` with `-png`. With Ghostscript, use `-sDEVICE=png16m`. PNG is lossless and supports transparency, making it better for PDFs with transparent backgrounds or when you need perfect fidelity. File sizes are larger than JPG.
Is there a way to convert PDF to JPG on Linux without installing tools?
Yes. Use LazyPDF's PDF to JPG tool in Firefox or Chromium — it runs in your browser without any installation and processes files locally. It's suitable for occasional conversions but doesn't offer the same DPI control or batch processing as command-line tools.