Skip to main content

Fast PDF to image converter with batch processing and multi-threading

Project description

pymupdf-img

Fast PDF to image converter with batch processing and multi-threading support using PyMuPDF.

Installation

pip install pymupdf-img
# or
uv pip install pymupdf-img

Quick start

Command Line

pdf2img document.pdf

Options:

  • -o, --output-dir: Output directory (default: output)
  • -p, --prefix: Image filename prefix
  • -r, --range: Page range, e.g., 1-10
  • -d, --dpi: Resolution in DPI (default: 95)
  • -e, --ext: Format: jpg, png, webp (default: jpg)
  • -q, --quality: Image quality 1-100 (default: 95)
  • -m, --max-size: Max width/height in pixels (default: 2500)
  • -b, --batch-size: Pages per batch (default: 25)
  • -a, --auto-alpha: PNG for transparency, otherwise ext format
from pymupdf_img import convert_pdf

# Basic conversion
images = convert_pdf("document.pdf")

# Advanced usage
images = convert_pdf(
    pdf_path="path/to/document.pdf",
    page_range=(1, 10),                 # None for all pages or (start, end) tuple
    output_dir="output/images",         # output directory
    img_prefix="img_",                  # prefix for image filenames
    dpi=150,                            # resolution
    ext="jpg",                          # output image format
    quality=95,                         # image quality for lossy formats
    max_size=2500,                      # max width/height in pixels
    batch_size=50,                      # number of pages to process per batch
    auto_alpha_format=True              # PNG if alpha channel detected, ext otherwise
)

Development

# Build the package
uv run python -m build
# Check the package
uv run twine check dist/* 
# Upload the package
uv run twine upload dist/*

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

pymupdf_img-0.1.1.tar.gz (16.9 kB view details)

Uploaded Source

Built Distribution

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

pymupdf_img-0.1.1-py3-none-any.whl (17.9 kB view details)

Uploaded Python 3

File details

Details for the file pymupdf_img-0.1.1.tar.gz.

File metadata

  • Download URL: pymupdf_img-0.1.1.tar.gz
  • Upload date:
  • Size: 16.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.1

File hashes

Hashes for pymupdf_img-0.1.1.tar.gz
Algorithm Hash digest
SHA256 51874e1b6829d3ddabcd7837a928c281f198a8428a033381cc4bb67e6167fe99
MD5 a411fa9f9b09279c474432ba7051d70b
BLAKE2b-256 75a5a2c06e98dedb608162582c5974848d1649d7dc5ed5dd15471fc6b4231408

See more details on using hashes here.

File details

Details for the file pymupdf_img-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: pymupdf_img-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 17.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.1

File hashes

Hashes for pymupdf_img-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8aaf524e29b84fa3eacf43dd25234968916fdacefd5b3460ca0cc077a3ecf08a
MD5 2538bf55bd237326dcf21a4289d74f2f
BLAKE2b-256 90a3def31f04e2ed0dc8b064935fc24722fd43fd4e898fa3f9429106ae69d932

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