A lightweight Python project to generate optimized PDFs from image archives.
It extracts .jpg files from a .7z archive, resizes them to fit an A4 page, and combines them into a single PDF.
- Extract
.jpgimages from.7zarchives - Resize/compress images for smaller PDF size
- Generate full-page PDFs with
fpdf2 - Logging with
loguru - Modern dependency & linting setup with uv
This project uses uv (a fast Python package/dependency manager).
Make sure you have it installed:
pip install uvThen, install dependencies:
uv syncThis will create and manage a .venv automatically.
Run the PDF generator:
uv run main.py(or whatever entrypoint you use β adjust the path accordingly).
The script will:
- Extract images from
input.7zinto the./imagesfolder - Resize them to fit an A4 page (at ~150 DPI)
- Generate
output.pdfin the project root
Run linting and auto-fixes with ruff:
uv run ruff check --fixFormat code:
uv run ruff formatpdf-generator/
βββ pyproject.toml # Dependencies & project config
βββ README.md # Documentation
βββ src/
β βββ pdf_generator.py
βββ images/ # Extracted images (generated at runtime)
βββ input.7z # Input archive
βββ main.py # Main application script
- Python 3.13+
fpdf2for PDF generationPillowfor image resizingpy7zrfor.7zextractionlogurufor loggingrufffor linting & formatting
MIT License β feel free to use and adapt.