IRONSOFTWAREHOME
Images To PDF
from ironpdf import *

# One or more images as a list. This example selects all JPEG images in a specific 'assets' folder.
image_files = [os.path.join("assets", f) for f in os.listdir("assets") if f.lower().endswith(('.jpg', '.jpeg'))]

directory_list = List[str]()
for i in range(len(image_files)):
    directory_list.Add(image_files[i])

# Converts the images to a PDF and save it.
ImageToPdfConverter.ImageToPdf(directory_list).SaveAs("composite.pdf")

# Also see PdfDocument.RasterizeToImageFiles() method to flatten a PDF to images or thumbnails
pip install ironpdf
Images To PDF

Images To PDF

The ImageToPdfConverter class creates PDF documents from images.

Call the ImageToPdfConverter.ImageToPdf function using a valid file path to an image to produce a new PDF document from that image.

Calling ImageToPdfConverter.ImageToPdf using a list of image paths will produce a single PDF document containing each image on separate pages.

  • Import necessary modules: FPDF for creating PDF files, Image from PIL for processing images, and os for file operations.
  • The method image_to_pdf takes one or multiple image paths and converts them into a PDF file, saving it at the specified output path.
  • Images are converted to RGB to ensure compatibility.
  • Temporary files are used to maintain the consistency of image formats.
  • The method handles single image paths and lists of image paths seamlessly.
Learn how to convert PDFs to images with IronPDF
View on GitHub

Ready to Get Started?

Version:2026.8just released

Key in blue circle

Get your free 30-day Trial Key instantly.

Your trial license will be sent to your email address

No limitations. 100% unlocked. No credit card.

bullet_checkedNo credit card or account creation requiredNo limitations. 100% unlocked. No credit card.
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried IronPDF
Book your free Live Demo
Booking Badge

Trusted by Millions of Engineers Worldwide

Iron Software's customer logos
Get Your No-Obligation Consult
Complete the form below or email sales@ironsoftware.com
Your details will always be kept confidential.
Trusted by Millions of Engineers Worldwide
Iron Software's customer logos
Get your free 30-day Trial Key instantly.
No credit card or account creation required