olkabul/image2pdf

Combines many image files into one multi-page PDF file

โ˜… 0Forks 0PythonGitHub โ†—Compare
ci-toolsimage-processingpdfpdf-generationpython

README

๐Ÿ–ผ๏ธ Image2PDF โ€“ Combine Images into a Single PDF

๐Ÿ“‘ Convert multiple images into a single PDF (f.e. many pages scanned in PNG format) ๐Ÿ–ผ๏ธ Supports PNG, JPG, JPEG, BMP, TIFF, WEBP
โšก Natural filename sorting (1.png, 2.png, 10.png)
โœ… Transparency-safe: flattens images with alpha channels
๐Ÿ› ๏ธ Simple CLI interface with customizable options


๐Ÿ”ง How to Run

Option 1: Quick Run

python make_pdf.py test_files -o output.pdf

Option 2: With Custom Extensions

python make_pdf.py test_files -o mydoc.pdf --extensions .png,.jpg

๐Ÿ“ Example Project Structure

image2pdf/
โ”œโ”€โ”€ make_pdf.py         # Main CLI script
โ”œโ”€โ”€ helpers.py          # Helper functions (sorting, loading, saving)
โ”œโ”€โ”€ test_files/         # Your input images (not tracked in git)
โ”œโ”€โ”€ requirements.txt
โ”œโ”€โ”€ .gitignore
โ”œโ”€โ”€ README.md

๐Ÿ–ผ๏ธ Supported Formats

  • .png
  • .jpg / .jpeg
  • .bmp
  • .tiff
  • .webp

๐Ÿšจ Features

  • Natural sort (no more 1, 10, 2 confusion)
  • Flatten transparency โ†’ ensures clean white background in PDF
  • Skips corrupted/unreadable images with a warning
  • Keeps the PDF small and lightweight

๐Ÿ“ฆ Install Requirements

pip install -r requirements.txt

โœ… Example Run

Input folder (test_files/):

Image (1).png
Image (2).png
Image (10).png

Command:

python make_pdf.py test_files -o my_album.pdf

Output:

โœ“ PDF created: my_album.pdf
   Pages: 3
   Included (in order):
   - Image (1).png
   - Image (2).png
   - Image (10).png

Contributors

olkabul

Issues