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.6 just released
Still Scrolling Icon

Still Scrolling?

Want proof fast?
run a sample watch your HTML become a PDF.