IRONSOFTWAREHOME
Extract Image
from ironpdf import *

# Open a 128 bit encrypted PDF
pdf = PdfDocument.FromFile("encrypted.pdf", "password")

# Get all images
all_images = pdf.ExtractAllImages()

for i, image in enumerate(all_images):
    image.SaveAs(f"output_image_{i}.png")

# Or even find the precise text and images for each page in the document
for index in range(pdf.PageCount):
    page_number = index + 1
    images = pdf.ExtractBitmapsFromPage(index)
pip install ironpdf
Extract Image

Extract Image

IronPDF for Python can extract all images embedded in a PDF document - either as saved image files or as in-memory bitmap objects - with the ability to target specific pages.

Getting Started

Load a PdfDocument using PdfDocument.FromFile, then call ExtractAllImages to retrieve every image in the document, or ExtractBitmapsFromPage to extract images from a specific page by its index.

Understanding the Code

  • PdfDocument.FromFile(path, password): Opens the PDF file. The second argument is the decryption password; omit it for unencrypted files.
  • ExtractAllImages(): Returns a list of all images found in the document across all pages. Each image in the list is an object with a SaveAs method for writing it to disk.
  • SaveAs(path): Saves an extracted image to the specified file path. The file format is determined by the extension (.png, .jpg, etc.).
  • ExtractBitmapsFromPage(pageIndex): Returns a list of AnyBitmap objects for all images on the specified zero-based page index. Use this when you need to work with image data in memory rather than writing to files.

Iteration Pattern

The example iterates over ExtractAllImages() using enumerate to assign a unique sequential index to each image filename, preventing overwrites when multiple images are extracted from the same document.

Learn how to work with PDF images using IronPDF for Python!

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