Ultra-fast PDF to PNG converter
Project description
fastpdf2png
Fast PDF to PNG converter. SIMD-optimized PNG encoding, automatic grayscale detection, multi-process scaling. MIT licensed.
Install
pip install fastpdf2png
Or build from source:
git clone https://github.com/nataell95/fastpdf2png.git && cd fastpdf2png
bash scripts/build.sh
Usage
CLI
./build/fastpdf2png input.pdf page_%03d.png 300 4 -c 2
Python
import fastpdf2png
images = fastpdf2png.to_images("doc.pdf") # list of PIL images
fastpdf2png.to_files("doc.pdf", "output/") # save PNGs to disk
data = fastpdf2png.to_bytes("doc.pdf") # raw PNG bytes
n = fastpdf2png.page_count("doc.pdf") # page count
# Batch processing — keep PDFium loaded between calls
with fastpdf2png.Engine() as pdf:
for path in my_pdfs:
images = pdf.to_images(path, dpi=150)
Node.js
const pdf = require("fastpdf2png");
pdf.toFiles("doc.pdf", "output/", { dpi: 150 });
const buffers = pdf.toBuffers("doc.pdf");
const count = pdf.pageCount("doc.pdf");
// Batch processing
const engine = new pdf.Engine();
await engine.toFiles("doc.pdf", "output/");
engine.close();
Performance
71-page PDF (mixed: text, charts, tables, images) on Apple M3 Max. All tools single-process, compression level 2.
| Engine | 72 DPI | 150 DPI | 300 DPI | File size |
|---|---|---|---|---|
| fastpdf2png | 531 pg/s | 323 pg/s | 145 pg/s | -38% |
| MuPDF | 119 | 37 | 12 | baseline |
| PyMuPDF | 101 | 30 | 9 | baseline |
With multiple workers (150 DPI):
| Workers | Pages/sec |
|---|---|
| 1 | 323 |
| 2 | 582 |
| 4 | 985 |
| 8 | 1536 |
How it works
PDFium renders pages to BGRA bitmaps. A SIMD pass (NEON/AVX2) checks if R==G==B — if so, the page is encoded as 8-bit grayscale (1/3 the data). A patched libdeflate compresses into a single IDAT chunk, assembled zero-copy into a valid PNG. Workers run as fork() processes with shared-memory atomic page counters.
CLI reference
fastpdf2png <input.pdf> <output_%03d.png> [dpi] [workers] [-c level]
fastpdf2png --info <input.pdf>
fastpdf2png --daemon
| Flag | Default | Description |
|---|---|---|
dpi |
300 | Output resolution |
workers |
1 | Parallel processes |
-c 0/1/2 |
0 | Compression: fast / medium / best |
--info |
Print page count | |
--daemon |
Persistent mode (stdin commands) |
Platforms
| OS | Arch | SIMD |
|---|---|---|
| macOS | arm64 | NEON |
| macOS | x86_64 | AVX2, SSE4.1 |
| Linux | x86_64 | AVX2, SSE4.1 |
| Linux | arm64 | NEON |
License
MIT. See LICENSE and THIRD_PARTY_LICENSES.md.
Built for Miruiq — AI-powered data extraction from PDFs and documents.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fastpdf2png-1.0.0-py3-none-manylinux_2_17_x86_64.whl.
File metadata
- Download URL: fastpdf2png-1.0.0-py3-none-manylinux_2_17_x86_64.whl
- Upload date:
- Size: 2.8 MB
- Tags: Python 3, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
494d3ef7b1ae66387ebf14c672c9b5c37ff9a75f8aa5a842723d4136f0838586
|
|
| MD5 |
47692a705bd2e75088b33effb58d28c7
|
|
| BLAKE2b-256 |
c238bb9d76374fa0cb04ee39ac3956baad3c5006c7891dd537526e5f48af6d37
|
Provenance
The following attestation bundles were made for fastpdf2png-1.0.0-py3-none-manylinux_2_17_x86_64.whl:
Publisher:
build.yml on nataell95/fastpdf2png
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fastpdf2png-1.0.0-py3-none-manylinux_2_17_x86_64.whl -
Subject digest:
494d3ef7b1ae66387ebf14c672c9b5c37ff9a75f8aa5a842723d4136f0838586 - Sigstore transparency entry: 1123233784
- Sigstore integration time:
-
Permalink:
nataell95/fastpdf2png@8d7ae57d88cb2241454a7d46bbff9fe35d36c692 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/nataell95
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build.yml@8d7ae57d88cb2241454a7d46bbff9fe35d36c692 -
Trigger Event:
push
-
Statement type:
File details
Details for the file fastpdf2png-1.0.0-py3-none-macosx_15_0_arm64.whl.
File metadata
- Download URL: fastpdf2png-1.0.0-py3-none-macosx_15_0_arm64.whl
- Upload date:
- Size: 2.6 MB
- Tags: Python 3, macOS 15.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
97dd7d4f2de60229b71e6f6066d5c730ea33535e40a2fdb7f8d04f6d3a788cb2
|
|
| MD5 |
e5ef5d9789d8d364ab4489b45cf53a40
|
|
| BLAKE2b-256 |
54f2cd1e2a9cdffc0690b1fb9af39410ddcee4dd805c8854057ea3bf530fb217
|
Provenance
The following attestation bundles were made for fastpdf2png-1.0.0-py3-none-macosx_15_0_arm64.whl:
Publisher:
build.yml on nataell95/fastpdf2png
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fastpdf2png-1.0.0-py3-none-macosx_15_0_arm64.whl -
Subject digest:
97dd7d4f2de60229b71e6f6066d5c730ea33535e40a2fdb7f8d04f6d3a788cb2 - Sigstore transparency entry: 1123233783
- Sigstore integration time:
-
Permalink:
nataell95/fastpdf2png@8d7ae57d88cb2241454a7d46bbff9fe35d36c692 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/nataell95
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build.yml@8d7ae57d88cb2241454a7d46bbff9fe35d36c692 -
Trigger Event:
push
-
Statement type: