Skip to main content
Back to Blog
PDF Tools·Admin User·14 min read

Linux JPG to PDF: How to Convert Images to PDF

Learn how to convert JPG to PDF on Linux using six free methods. Includes Ubuntu Terminal commands, ImageMagick, img2pdf, Python and online conversion.

Linux JPG to PDF: convert images to PDF using img2pdf, ImageMagick, Python, LibreOffice, gscan2pdf and OneFileKit.

Looking for a reliable Linux JPG to PDF conversion method? Whether you're using Ubuntu, Debian, Fedora, Linux Mint, or another Linux distribution, you can convert JPG images into PDF documents using free command-line utilities, Python libraries, desktop applications, or online converters.

You might need to turn a scanned certificate into a PDF, combine multiple photographs into one document, or automate image-to-PDF conversion for hundreds of files.

Linux offers several ways to accomplish these tasks without purchasing Adobe Acrobat or another commercial PDF editor.

In this guide, you'll learn six practical methods for converting JPG to PDF on Linux, including img2pdf, ImageMagick, Python, LibreOffice Draw, gscan2pdf, and OneFileKit.

We'll also cover batch conversion, image quality, page dimensions, common errors, and the difference between JPG-to-PDF conversion and PDF compression.

If you prefer converting images without installing additional software, try the OneFileKit JPG to PDF converter.

Quick Answer: How to Convert JPG to PDF on Linux

One convenient command-line method uses img2pdf.

On Ubuntu or Debian, install it using:

sudo apt update
sudo apt install img2pdf

Convert one JPG image:

img2pdf photo.jpg -o output.pdf

Convert several images into one PDF:

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

The second command creates one PDF containing three pages, in the order specified.

img2pdf is particularly useful because it can embed supported JPEG image data directly into PDFs without unnecessary re-encoding.

For a graphical alternative, use OneFileKit JPG to PDF through your Linux browser.

Why Convert JPG Images to PDF on Linux?

JPG and PDF are different file formats.

JPG is commonly used for photographs and other raster images, while PDF is a document format that can contain multiple pages and different content types.

Converting images into PDFs provides several benefits.

1. Combine Multiple Images

Create one PDF containing several JPG images.

2. Organize Scanned Documents

Turn scanned receipts, invoices, certificates, and forms into organized documents.

3. Automate Repetitive Tasks

Use Bash scripts or Python programs to convert multiple images automatically.

4. Prepare Documents for Printing

Create PDFs with suitable page dimensions and image placement.

5. Share Documents

Combine related images into one file for email or online submissions.

6. Work Offline

Linux provides local conversion utilities that don't require uploading documents to an external service.

7. Integrate Conversion Into Applications

Developers can build JPG-to-PDF functionality into document-management systems and backend services.

Method 1: Convert JPG to PDF on Linux Using img2pdf

img2pdf is an open-source image-to-PDF conversion utility.

It supports converting images into PDFs and can avoid unnecessary JPEG re-encoding for supported inputs.

This makes it a useful choice when preserving existing image data is important.

Step 1: Install img2pdf

On Ubuntu or Debian:

sudo apt update
sudo apt install img2pdf

On Fedora, check whether img2pdf is available through your configured package repositories:

sudo dnf install img2pdf

Package availability may vary by distribution and release.

Step 2: Open Terminal

Navigate to the folder containing your JPG image.

For example:

cd ~/Pictures

Step 3: Convert a Single JPG

Run:

img2pdf photo.jpg -o photo.pdf

This creates photo.pdf.

Step 4: Convert Multiple JPG Images

img2pdf image1.jpg image2.jpg image3.jpg -o combined.pdf

The resulting PDF contains the three images as separate pages.

Step 5: Create an A4 PDF

You can specify a page size:

img2pdf --pagesize A4 photo.jpg -o photo-a4.pdf

The image is placed within the specified page dimensions according to the utility's layout rules.

Step 6: Check the Output

Open the PDF using your preferred Linux PDF viewer.

Verify image clarity, orientation, and page dimensions.

Advantages of img2pdf

  • Free and open source.

  • Useful for Terminal workflows.

  • Supports multiple images.

  • Supports page-size configuration.

  • Can preserve JPEG image data without re-encoding.

  • Suitable for automation.

Limitations

Some image formats require additional processing.

Image dimensions, PDF layout, and colour-space compatibility can affect output.

For full documentation, visit the official img2pdf project.

Method 2: Convert JPG to PDF Using ImageMagick

ImageMagick is an image-processing toolkit available on Linux and other operating systems.

It supports many image formats and provides command-line tools for image manipulation.

Step 1: Install ImageMagick

On Ubuntu or Debian:

sudo apt install imagemagick

On Fedora:

sudo dnf install ImageMagick

Step 2: Check the Installed Version

For ImageMagick 7:

magick -version

Some Linux distributions provide ImageMagick 6, where the command may be convert instead of magick.

Step 3: Convert JPG to PDF

With ImageMagick 7:

magick input.jpg output.pdf

Step 4: Convert Multiple Images

magick image1.jpg image2.jpg image3.jpg combined.pdf

Step 5: Review the PDF

Open the resulting file and inspect its pages.

Important: ImageMagick PDF Security Policies

Some Linux installations restrict PDF reading or writing through ImageMagick's security policy.

You may encounter an error similar to:

attempt to perform an operation not allowed
by the security policy 'PDF'

This is a security restriction, not necessarily a damaged image.

Avoid disabling PDF security restrictions globally simply to perform a conversion.

For ordinary JPG-to-PDF tasks, consider img2pdf or another compatible utility instead.

Advantages

  • Supports extensive image processing.

  • Can resize, rotate, and modify images.

  • Useful for scripted workflows.

  • Available on multiple platforms.

Limitations

  • PDF output may be restricted by security policies.

  • Image processing can introduce recompression.

  • Large images may consume substantial memory.

  • Command syntax differs between major versions.

Official documentation: ImageMagick.

Method 3: Convert JPG to PDF on Linux Using Python

Python is useful when you want to automate image conversion or integrate it into an application.

One option is the Pillow image-processing library.

Step 1: Install Python

Many Linux distributions already include Python.

Check the installed version:

python3 --version

Step 2: Create a Virtual Environment

python3 -m venv pdf-env
source pdf-env/bin/activate

On some distributions, you may need to install the Python virtual-environment package first.

Step 3: Install Pillow

python -m pip install Pillow

Step 4: Create the Python Script

Create a file named jpg_to_pdf.py:

from PIL import Image

with Image.open("input.jpg") as source:
    image = source.convert("RGB")

    try:
        image.save(
            "output.pdf",
            "PDF",
            resolution=150.0
        )
    finally:
        image.close()

print("PDF created successfully")

Step 5: Run the Script

python jpg_to_pdf.py

Step 6: Verify the Output

Open output.pdf in a compatible PDF viewer.

Convert Multiple JPG Files Into One PDF

You can also combine multiple images:

from pathlib import Path
from PIL import Image

files = sorted(Path("images").glob("*.jpg"))

if not files:
    raise ValueError("No JPG files found")

images = []

try:
    for path in files:
        with Image.open(path) as source:
            images.append(source.convert("RGB"))

    images[0].save(
        "combined.pdf",
        "PDF",
        save_all=True,
        append_images=images[1:],
        resolution=150.0
    )
finally:
    for image in images:
        image.close()

print("Combined PDF created")

Advantages

  • Useful for automation.

  • Supports custom processing.

  • Can combine multiple images.

  • Integrates with backend applications.

  • Works offline after installation.

Limitations

  • Requires Python knowledge.

  • Large images may consume significant memory.

  • Conversion settings affect output size and quality.

  • Pillow may re-encode images rather than preserve their original JPEG data.

Official reference: Pillow PDF documentation.

Method 4: Convert JPG to PDF Using LibreOffice Draw

LibreOffice Draw is a graphical application that can work with images and export documents to PDF.

It is useful when you want to place images on pages manually and control their layout.

Step 1: Install LibreOffice

On Ubuntu or Debian:

sudo apt install libreoffice-draw

Step 2: Open LibreOffice Draw

Launch Draw from your application menu.

Step 3: Insert Your JPG

Create a document and select the image insertion option.

Choose the JPG image.

Step 4: Adjust the Layout

Resize and position the image on the page.

Preserve the image's aspect ratio.

Step 5: Add More Pages if Necessary

For multiple images, create additional pages and insert the required images.

Step 6: Export to PDF

Select the PDF export option from the File menu.

Step 7: Save the Document

Choose a filename and destination.

Step 8: Verify the Result

Open the PDF and check the page layout.

Advantages

  • Graphical interface.

  • Supports manual layout adjustments.

  • Useful for documents containing images and other content.

  • Available on Linux.

  • Can work offline.

Limitations

Manual page creation is slower for large image collections.

It is better suited to layout-oriented documents than high-volume automated conversion.

Official reference: LibreOffice.

Method 5: Convert JPG to PDF Using gscan2pdf

gscan2pdf is a graphical scanning and document-processing application commonly available on Linux.

It can import images and save them as multi-page PDFs.

Step 1: Install gscan2pdf

On Ubuntu or Debian:

sudo apt install gscan2pdf

Step 2: Open the Application

Launch gscan2pdf.

Step 3: Import JPG Images

Use the available file-import function to add images.

Step 4: Review the Pages

Check the imported images and their sequence.

Step 5: Arrange the Images

Reorder or rotate pages where necessary.

Step 6: Save as PDF

Choose the PDF output format through the application's Save workflow.

Step 7: Verify the Result

Open the resulting PDF.

Advantages

  • Graphical interface.

  • Useful for scanned documents.

  • Supports multiple pages.

  • Works offline.

  • Suitable for users who prefer desktop applications.

Limitations

  • Requires installation.

  • Features depend on the installed version.

  • May include more scanning-related functionality than occasional users need.

Official project: gscan2pdf.

Method 6: Convert JPG to PDF Online on Linux Using OneFileKit

You don't need to install a desktop application or use Terminal to convert JPG images into PDF.

OneFileKit provides a free browser-based converter.

Step 1: Open Your Browser

Launch Firefox, Chrome, Chromium, or another compatible browser.

Step 2: Visit OneFileKit

Open the OneFileKit JPG to PDF converter.

Step 3: Upload Your Images

Select one or multiple images.

Supported formats include:

  • JPG

  • JPEG

  • PNG

  • WebP

  • BMP

The tool advertises support for up to 40 images and a maximum of 50 MB per image, subject to its current configured limits.

Step 4: Arrange Your Images

Drag the images into the required order.

Step 5: Rotate or Remove Images

Correct the orientation of any incorrectly rotated images.

Remove unwanted files.

Step 6: Convert JPG to PDF

Click Convert to PDF.

Step 7: Download Your Document

Save the resulting PDF.

Step 8: Verify the Output

Open the PDF and check:

  • Page order.

  • Image clarity.

  • Orientation.

  • Page dimensions.

  • Cropping.

  • File size.

Advantages of OneFileKit

  • Free browser-based conversion.

  • No dedicated desktop installation.

  • Supports multiple images.

  • Allows image reordering and rotation.

  • Supports several image formats.

  • Suitable for occasional conversion tasks.

Limitations

An internet connection is required.

Upload limits apply.

For confidential documents, review the service's privacy and retention policies before uploading.

Convert JPG to PDF Online for Free

Six Linux JPG to PDF Methods Compared

Method

Interface

Offline

Best for

img2pdf

Terminal

Yes

JPEG preservation and batch conversion

ImageMagick

Terminal

Yes

Image processing and conversion

Python + Pillow

Code

Yes

Automation and applications

LibreOffice Draw

Graphical

Yes

Custom document layouts

gscan2pdf

Graphical

Yes

Scanned documents

OneFileKit

Browser

No

Quick online conversion

Which Method Should You Choose?

Choose img2pdf for straightforward command-line conversion.

Choose ImageMagick when you also need image processing.

Choose Python for automation and custom applications.

Choose LibreOffice Draw for manually arranging images in a document.

Choose gscan2pdf for scanned records.

Choose OneFileKit for converting images through a browser without installing software.

How to Convert Multiple JPG Images Into One PDF on Linux

Suppose you have five images:

  • page1.jpg

  • page2.jpg

  • page3.jpg

  • page4.jpg

  • page5.jpg

You want to create:

complete-document.pdf

Using img2pdf

Run:

img2pdf \
  page1.jpg \
  page2.jpg \
  page3.jpg \
  page4.jpg \
  page5.jpg \
  -o complete-document.pdf

The resulting PDF contains five pages.

Using OneFileKit

  1. Open OneFileKit JPG to PDF.

  2. Upload all five images.

  3. Arrange them in the correct order.

  4. Convert to PDF.

  5. Download the document.

  6. Verify the page sequence.

For a detailed guide, read How to Convert Multiple JPG Files to One PDF.

How to Batch Convert JPG Files to PDF on Linux

Batch conversion is useful when you need to process many images.

For example, you may have 100 scanned JPG files and want to create one PDF from each image.

Example Bash Script

First, install img2pdf.

Then create batch_convert.sh:

#!/usr/bin/env bash
set -euo pipefail

mkdir -p converted

for image in ./*.jpg; do
    [ -f "$image" ] || continue

    name=$(basename "$image" .jpg)

    img2pdf "$image" \
      -o "converted/$name.pdf"
done

echo "Batch conversion completed."

Run:

bash batch_convert.sh

What Does This Script Do?

It:

  1. Finds JPG images in the current directory.

  2. Creates an output directory.

  3. Converts each image into a PDF.

  4. Saves the resulting PDFs.

  5. Continues until all matching files are processed.

Important Considerations

  • Verify filenames before conversion.

  • Avoid overwriting existing documents.

  • Check available storage.

  • Validate input files.

  • Handle conversion errors.

  • Use safe directory permissions.

  • Keep original images.

For larger systems, consider adding logging, retry handling, and resource limits.

How to Convert JPG to PDF on Ubuntu

Ubuntu users have several free options.

Terminal Method

Install img2pdf:

sudo apt install img2pdf

Convert the image:

img2pdf input.jpg -o output.pdf

Graphical Method

Use LibreOffice Draw or gscan2pdf.

Online Method

Open OneFileKit JPG to PDF in Firefox or another compatible browser.

Upload the image and download the resulting PDF.

These methods can also be suitable for other Linux distributions, subject to package availability.

How to Convert JPG to PDF Without Losing Quality on Linux

Converting JPG to PDF does not automatically improve or reduce image quality.

The result depends on the original image and the conversion method.

Use High-Quality Original Images

Start with the best-quality source files available.

Avoid Unnecessary JPEG Re-Encoding

When supported, use a method that preserves existing JPEG image data.

Preserve Aspect Ratio

Avoid stretching images.

Check Page Dimensions

Choose a suitable page size for the intended use.

Avoid Excessive Resizing

Enlarging low-resolution images does not restore missing detail.

Inspect the Output

Check small text, photographs, scanned signatures, and image boundaries.

For more quality recommendations, read JPG to PDF High Quality: 7 Tips for Clear PDFs.

How to Create an A4 PDF From JPG on Linux

A4 is a commonly used document size measuring 210 × 297 mm.

Using img2pdf, you can specify A4 page dimensions:

img2pdf --pagesize A4 input.jpg -o output-a4.pdf

This places the image onto an A4-sized PDF page.

What If the Image Doesn't Fit?

The tool's layout rules determine how the image is positioned.

Check the resulting PDF and choose suitable image or layout settings.

Avoid stretching the image because it can distort its proportions.

JPG to PDF vs PDF to JPG on Linux

These are opposite conversion operations.

Feature

JPG to PDF

PDF to JPG

Input

JPG images

PDF document

Output

PDF document

JPG images

Main purpose

Create PDFs from images

Convert PDF pages into images

Multiple pages

Can combine images

Can export page images

Common use

Scanned documents

Image previews

When Should You Use JPG to PDF?

Use JPG to PDF when you want to create a document from one or more images.

When Should You Use PDF to JPG?

Use PDF to JPG when you want to save document pages as image files.

OneFileKit provides both tools:

JPG to PDF Converter

PDF to JPG Converter

Does Converting JPG to PDF Reduce File Size?

Not necessarily.

The resulting PDF size depends on:

  • Original JPG file size.

  • Image resolution.

  • Number of images.

  • PDF compression settings.

  • Image processing.

  • Embedded resources.

For example, combining ten JPG images into one PDF does not guarantee that the PDF will be smaller than the combined images.

If you need to reduce the size of an existing PDF, try OneFileKit Compress PDF.

Stronger compression may reduce image clarity.

How to Convert Scanned JPG Documents Into PDF on Linux

Scanned documents are often saved as JPG images.

You can combine them into PDFs for sharing or archiving.

Common Examples

  • Receipts

  • Certificates

  • Invoices

  • Application forms

  • Academic records

  • Business documents

  1. Gather the scanned images.

  2. Check that every image is readable.

  3. Rotate incorrectly oriented pages.

  4. Arrange the images in the correct order.

  5. Convert the images into PDF.

  6. Review the resulting document.

  7. Save the original images.

Does JPG to PDF Make Text Searchable?

Not automatically.

A basic JPG-to-PDF conversion generally creates a document containing images.

OCR, or Optical Character Recognition, is required to recognize text inside scanned pages.

For supported documents, use OneFileKit PDF OCR.

Common Linux JPG to PDF Errors and Fixes

1. Command Not Found

Problem: The conversion utility isn't installed.

Solution: Install the appropriate package and verify its executable name.

2. ImageMagick Security Policy Error

Problem: ImageMagick blocks PDF output.

Solution: Use a suitable alternative such as img2pdf rather than weakening security policies unnecessarily.

3. Permission Denied

Problem: The user cannot read the input image or write the output.

Solution: Check file and directory permissions.

4. Unsupported Image Format

Problem: The selected file isn't supported.

Solution: Verify the actual file format and convert it to a compatible format if necessary.

5. File Not Found

Problem: The input filename or path is incorrect.

Solution: Check the working directory and filename.

6. PDF Appears Blurry

Problem: The source image is low-resolution or has been resized.

Solution: Use a higher-quality original and avoid unnecessary recompression.

7. PDF Is Too Large

Problem: The document contains multiple high-resolution images.

Solution: Review image sizes and use appropriate compression if needed.

8. Incorrect Page Order

Problem: Images were supplied in the wrong sequence.

Solution: Specify filenames in the intended order or rename them numerically.

Is It Safe to Convert JPG to PDF on Linux?

Local JPG-to-PDF conversion avoids uploading documents to an online service.

However, local processing alone does not guarantee security.

Security Recommendations

  • Install software from trusted sources.

  • Keep packages updated.

  • Validate input images.

  • Avoid unnecessary administrator privileges.

  • Use safe output directories.

  • Protect sensitive documents.

  • Limit resource usage for untrusted files.

  • Keep original images.

  • Review software security advisories.

For online conversion, review the provider's privacy and retention policies before uploading confidential documents.

Explore these five relevant resources:

  1. OneFileKit JPG to PDF — Convert JPG images into PDF documents.

  2. How to Change JPG to PDF: 5 Easy Methods — Learn general JPG-to-PDF conversion methods.

  3. How to Convert Multiple JPG Files to One PDF — Combine several images into one PDF.

  4. JPG to PDF High Quality — Learn how to preserve image clarity.

  5. OneFileKit Compress PDF — Reduce PDF file size.

Final Thoughts

Learning Linux JPG to PDF conversion gives you several free ways to turn images into shareable PDF documents.

For simple Terminal conversion, img2pdf is a useful starting point, particularly when preserving JPEG image data is important.

ImageMagick provides additional image-processing capabilities, while Python supports automation and custom workflows.

LibreOffice Draw and gscan2pdf offer graphical alternatives for users who prefer desktop applications.

For a simple browser-based solution, visit the OneFileKit JPG to PDF converter.

Upload your images, arrange them in the correct order, and download your PDF.

Keep your original JPG files and review the resulting document before sharing or submitting it.

Frequently Asked Questions

How do I convert JPG to PDF on Linux?

You can use img2pdf, ImageMagick, Python, LibreOffice Draw, gscan2pdf, or a browser-based converter such as OneFileKit.

What is the easiest Linux JPG to PDF command?

For supported images, run img2pdf input.jpg -o output.pdf after installing img2pdf.

How do I convert multiple JPG images into one PDF on Ubuntu?

Use img2pdf image1.jpg image2.jpg image3.jpg -o combined.pdf.

Can I convert JPG to PDF on Linux without Terminal?

Yes. Use LibreOffice Draw, gscan2pdf, or OneFileKit through a browser.

Is img2pdf free?

Yes. img2pdf is an open-source image-to-PDF conversion utility.

Can ImageMagick convert JPG to PDF?

Yes, when its installed configuration and security policy permit PDF output.

Can Python convert JPG images to PDF on Linux?

Yes. Python libraries such as Pillow support image-to-PDF conversion.

Does JPG to PDF conversion reduce quality?

Not necessarily. Some methods preserve existing JPEG image data, while others may resize or recompress images.

Can I create an A4 PDF from JPG on Linux?

Yes. Tools such as img2pdf support specifying A4 page dimensions.

What is a free online JPG-to-PDF converter for Linux?

OneFileKit provides a free browser-based JPG-to-PDF converter with support for multiple images and image ordering.

  • #JPG to PDF
  • #Linux
  • #Ubuntu
  • #Debian
  • #Fedora
  • #img2pdf
  • #ImageMagick
  • #Python
  • #Pillow
  • #LibreOffice
  • #Image to PDF
  • #Free PDF Converter

Stay Updated

Get the latest tips, guides and tool updates directly in your inbox.