Skip to main content

Fast parallel PDF image extractor

Project description

python-pdfimgextract

🚀 Overview

python-pdfimgextract is a high-performance PDF image extraction tool designed to maximize throughput through multiprocessing.

The project focuses on speed, reliability, and efficient parallel processing, enabling large PDFs with hundreds of high-resolution images to be processed significantly faster than traditional single-threaded approaches.


✨ Features

Feature Description
⚡ Parallel Extraction Utilizes multiprocessing to decode images across multiple CPU cores
🛡️ Atomic Writes Prevents partially written files during crashes
🧹 Deduplication Optional removal of identical images
📊 Progress Tracking Real-time progress bar during extraction
🛑 Graceful Interrupts Safe handling of SIGINT and termination signals
💻 Clean CLI Simple command-line interface

📥 Installation

pip install pdfimgextract

🛠️ Usage

Basic usage:

pdfimgextract INPUT_PDF OUTPUT_DIR NUMBER_OF_PROCESSES

Example:

pdfimgextract manga.pdf output 16

Optional usage (flags):

pdfimgextract -i input.pdf -o output_dir -p 8
pdfimgextract -i input.pdf -o output_dir -d hash
pdfimgextract -i input.pdf -o output_dir --overwrite

Arguments

-i / --input         Path to input PDF
-o / --output        Output directory
-p / --parallelism   Number of worker processes (default: 8)
-d / --dedup         Deduplication method: xref (default) or hash (precise but slower)
--overwrite          Overwrite existing files

If not specified, the tool defaults to:

  • 8 workers
  • xref deduplication

📊 Performance & Benchmark

🖥️ Test Environment

OS: Windows 11
CPU: 28 cores
Input File: 491 MB PDF
Extracted Images: 230
Image Size Range: ~2MB – 10MB


📈 Results

Proc Time (s) Speedup Efficiency RAM (MB)
1 111.88 1.00x 100% 349
2 56.98 1.96x 98% 626
4 32.41 3.45x 86% 1159
8 20.16 5.55x 69% 2254
16 14.24 7.86x 49% 4423
32 11.41 9.81x 31% 7309
64 11.67 9.59x 15% 9306

🧠 Analysis

Scaling

  • Near-linear scaling up to ~4 processes
  • Strong gains up to ~16
  • Performance plateaus around ~32

CPU Efficiency

  • Very high at low parallelism (~98% at 2 workers)
  • Gradual drop due to scheduling and contention
  • Diminishing returns at 64 and beyond workers

Memory Usage

  • RAM scales almost linearly with process count
  • Each worker holds its own decoding state
  • Large images amplify memory consumption

Examples:

  • 8 workers → ~2.2 GB
  • 32 workers → ~7.3 GB
  • 64 workers → ~9.3 GB

I/O Bottleneck

  • Parallel writes saturate disk bandwidth
  • Causes worker stalls at high process counts
  • Main limiter beyond ~32 workers

🏁 Optimal Range

Recommended configuration:

8 – 16 workers

Best balance between:

  • Speed
  • Efficiency
  • Memory usage
  • I/O pressure

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pdfimgextract-1.6.2.tar.gz (16.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pdfimgextract-1.6.2-py3-none-any.whl (18.5 kB view details)

Uploaded Python 3

File details

Details for the file pdfimgextract-1.6.2.tar.gz.

File metadata

  • Download URL: pdfimgextract-1.6.2.tar.gz
  • Upload date:
  • Size: 16.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for pdfimgextract-1.6.2.tar.gz
Algorithm Hash digest
SHA256 98dfc9542ac40fba4889fec746afb2154725e14dc4aa2a3f7db5f8533fca502d
MD5 737b161e2cc5e863ff9b48ae15059e07
BLAKE2b-256 330d900bada495fdbcf7eb81d3a66e8731ab1575d873dd4a5f2d4dd5b02fff99

See more details on using hashes here.

File details

Details for the file pdfimgextract-1.6.2-py3-none-any.whl.

File metadata

  • Download URL: pdfimgextract-1.6.2-py3-none-any.whl
  • Upload date:
  • Size: 18.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for pdfimgextract-1.6.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e1bb6d6435d9d75030ca43708783119b1cb4954da6af9be830d58e1e86f518d6
MD5 e754c1ba1dfe4a6d048902163898b2da
BLAKE2b-256 68769cd41bd4da4c6cddad12e09f8a74b62ca3c3fe38c801c67fde48f3e9dde8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page