How to Extract Images from PDF in Python using PyMuPDF and Pillow

How to Extract Images from PDF in Python using PyMuPDF and Pillow

Learn how to extract and save images from PDF files in Python using PyMuPDF and Pillow libraries. We will write a Python code to extract images from PDF files and save them in the local disk using PyMuPDF and Pillow libraries.

Learn how to extract and save images from PDF files in Python using PyMuPDF and Pillow libraries.

In this tutorial, we will write a Python code to extract images from PDF files and save them in the local disk using PyMuPDF and Pillow libraries.

With PyMuPDF, you are able to access PDF, XPS, OpenXPS, epub and many other extensions. It should run on all platforms including Windows, Mac OSX and Linux.

Let's install it along with Pillow:

pip3 install PyMuPDF Pillow

Copy

Open up a new Python file and let's get started. First, let's import the libraries:

import fitz ## PyMuPDF
import io
from PIL import Image

Copy

I'm gonna test this with this PDF file, but you're free to bring and PDF file and put it in your current working directory, let's load it to the library:

## file path you want to extract images from
file = "1710.05006.pdf"
## open the file
pdf_file = fitz.open(file)

python images web-development

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Hire Python Developer | Python web development company india

Hire Python Developer from us for Scalable, Secure & Robust Python Web development Solutions. Strict NDA | 16+ Years Exp| 2500+ Clients| 450+ Experts

Hire Expert Python Developers | Hire Top Python Developers

For your custom Python development projects, hire our dedicated Python Developers on an hourly/full-time basis. We are experts in working with latest python frameworks.

Top Python Web Development Companies That Deliver Staggering Assistance To Enterprises

You must have wondered so many times which programming language is capable of deploying modern technology concepts and bringing unthinkable systems into digital reality. Well! The answer to your quest is Python.  It is an incredible potential programming language winning the IT marketplace with its superpower to create solutions for scientific researches, the healthcare system, and almost every industry needs. It

Hire Python Developers

Are you looking for experienced, reliable, and qualified Python developers? If yes, you have reached the right place. At **[HourlyDeveloper.io](https://hourlydeveloper.io/ "HourlyDeveloper.io")**, our full-stack Python development services...

Hire Python Developers India

Looking to build robust, scalable, and dynamic responsive websites and applications in Python? At **[HourlyDeveloper.io](https://hourlydeveloper.io/ "HourlyDeveloper.io")**, we constantly endeavor to give you exactly what you need. If you need to...