Skip to main content

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.

License Platform

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

Architecture

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.

Miruiq

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

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

fastpdf2png-1.0.0-py3-none-manylinux_2_17_x86_64.whl (2.8 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64

fastpdf2png-1.0.0-py3-none-macosx_15_0_arm64.whl (2.6 MB view details)

Uploaded Python 3macOS 15.0+ ARM64

File details

Details for the file fastpdf2png-1.0.0-py3-none-manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for fastpdf2png-1.0.0-py3-none-manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 494d3ef7b1ae66387ebf14c672c9b5c37ff9a75f8aa5a842723d4136f0838586
MD5 47692a705bd2e75088b33effb58d28c7
BLAKE2b-256 c238bb9d76374fa0cb04ee39ac3956baad3c5006c7891dd537526e5f48af6d37

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fastpdf2png-1.0.0-py3-none-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for fastpdf2png-1.0.0-py3-none-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 97dd7d4f2de60229b71e6f6066d5c730ea33535e40a2fdb7f8d04f6d3a788cb2
MD5 e5ef5d9789d8d364ab4489b45cf53a40
BLAKE2b-256 54f2cd1e2a9cdffc0690b1fb9af39410ddcee4dd805c8854057ea3bf530fb217

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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