Skip to main content

Ultra-fast PDF to PNG converter

Project description

Built for Miruiq — AI-powered data extraction from PDFs and documents.

Miruiq

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

Worker scaling

Benchmark

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.

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.1.0-py3-none-manylinux_2_17_x86_64.whl (2.8 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64

fastpdf2png-1.1.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.1.0-py3-none-manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for fastpdf2png-1.1.0-py3-none-manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 6b3fd13a894d8d36b675e3f218149d299f10d1f83c2386df5ac915f17addab31
MD5 c62c05747421e1c4f9e2968052614f34
BLAKE2b-256 afb28edf4784b573b3f65a669fab9318af8564a984d4dba07b16dc9f44e22e14

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastpdf2png-1.1.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.1.0-py3-none-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for fastpdf2png-1.1.0-py3-none-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 2532ba0e73033028e80f0338cde7f99afe063b5c2a56a85e5362419b9eaa1e60
MD5 8af6bb195ed56cc63b8503d96fdb4040
BLAKE2b-256 40117c340d95a631f9b6ff1c12b850047ac136fe74a5ffaf3ff8cae2be5e6a7d

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastpdf2png-1.1.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