skillfed

img2pdf

Lossless conversion of raster images to PDF.

img2pdf v0.6.3 2.3M downloads/30d#3,139 on PyPI
Copyleft license AGING released

What it is and what it does

img2pdf is a Python library and command-line tool that converts raster images into PDF files while preserving image quality and minimizing file size. Unlike general-purpose image converters, it avoids re-encoding pixel data whenever possible—for JPEG, JPEG2000, PNG, TIFF, and JBIG2 formats, the image data is embedded directly into the PDF container with only minimal PDF overhead added. For other formats or color spaces, it applies appropriate compression filters (PNG Paeth, CCITT Group 4, or flate) before embedding.

The package works both as a standalone command-line tool and as a Python library. It handles single images, multiple images, and batch operations from directories or glob patterns. It depends on Pillow for image metadata extraction and format conversion when needed, and pikepdf for PDF handling. The tool is designed to handle large images efficiently by avoiding full decompression into memory during the conversion process.

Use it for:

  • Batch convert a folder of photographs to PDF without quality loss or file bloat for archival or sharing.
  • Create a multi-page PDF from a sequence of scanned document images while preserving original resolution.
  • Embed images directly into PDF containers from a Python script with minimal overhead and maximum speed.
  • Process JPEG or PNG images to PDF in a pipeline (e.g., from a scanner or camera) without intermediate re-encoding.
  • Handle CMYK or monochrome images that require specific PDF encoding while keeping file sizes small.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Converts raster images to PDF without re-encoding pixel data, prioritizing lossless output, small file size, and speed by embedding images directly into the PDF container when possible.

Yes. The package fills a specific, well-defined niche: lossless image-to-PDF conversion with minimal file size and fast processing. Low install friction, no security vulnerabilities, and broad format support make it a solid choice for image-to-PDF workflows. The copyleft license is a minor consideration only if you plan to redistribute derivative code. Aging maintenance status (282 days since last release) is not a blocker for a stable, mature tool, but monitor for any future issues.

Install

img2pdf on PyPI

pip

pip install img2pdf

uv

uv add img2pdf

poetry

poetry add img2pdf

Installing img2pdf

Before you install

Low friction install with two stable runtime dependencies (Pillow and pikepdf). Package shows aging maintenance status with last release 282 days ago, but has been actively maintained since 2014 and supports current Python versions.

License in practice

Licensed under LGPLv3 (copyleft). You may use and modify the package freely, but any derivative works must also be licensed under LGPLv3 and source code must be made available.

Quickstart

pip install img2pdf

import img2pdf

with open("output.pdf", "wb") as f:
    f.write(img2pdf.convert('input.jpg'))

Input images must be provided as files or file handles; img2pdf needs to seek in the file descriptor and cannot work from pure in-memory byte streams alone.

Verify before relying

  • Whether pikepdf is always required or only for certain image formats or operations
  • Performance characteristics on very large images relative to other tools
  • Compatibility with all PDF readers for directly-embedded formats beyond Adobe Acrobat Reader

Package facts

License not declared (copyleft)
Python support supports the current Python release (>=3.5)
Install friction low — pure-Python wheel
Runtime dependencies 2 — Pillow, pikepdf
Maintenance aging — 282 days since the last release
First released
Downloads 2,325,033/month — #3,139 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: img2pdf-0.6.3-py3-none-any.whl

License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)

Tags

image to pdf conversionlossless image pdfbatch convert images pdfraster to pdffast image pdf without reencodingcommand line image pdf toolpython image pdf library
image-conversionpdf-generationcli-tool

More Graphics packages