A simple Python CLI tool to convert all pages of a PDF file into images using Typer and PyMuPDF (imported as fitz).
- No project setup required: Uses PEP 723 inline dependencies and can be run directly with uv.
- Fast and easy: Converts each page of a PDF to an image file in your chosen format.
- Convert every page of a PDF to an image (PNG, JPG, etc.)
- Specify output directory and filename prefix
- Simple CLI interface powered by Typer
- No need for a virtual environment or requirements file
- Python 3.8+
- uv (for running with inline dependencies)
No installation required! Just clone/download this repo and run the script with uv:
uv run main.py pdf-to-images input.pdf output_dirinput.pdf: Path to your PDF fileoutput_dir: Directory where images will be saved (created if it doesn't exist)
--prefix: Prefix for output image files (default:slide_)--image-format: Image format (default:png)
uv run main.py pdf-to-images slides.pdf images/ --prefix page_ --image-format jpguv run main.py pdf-to-images <PDF_PATH> <OUTPUT_DIR> [--prefix PREFIX] [--image-format FORMAT]Example output files:
output_dir/slide_1.pngoutput_dir/slide_2.png- ...
- The package is installed as
pymupdf, but for historical reasons, you import it asfitzin your Python code. As of PyMuPDF 1.24.3+, you can also useimport pymupdf, butimport fitzremains widely supported and is used in most examples. Read more here.
Pull requests and issues are welcome! Please open an issue to discuss any major changes before submitting a PR.
MIT License. See LICENSE for details.