img2pdf
Convert images to PDF
TLDR
Convert one or more images to a single PDF, each image being on its own page
Convert only the first frame of a multi-frame image to PDF
Auto orient the image, use a specific page size in landscape mode, and set a border of specific sizes horizontally and vertically
Shrink only larger images to a rectangle of specified dimensions inside a page with a specific size
Convert an image to PDF and specify metadata for the resulting file
SYNOPSIS
img2pdf [OPTION...] [FILE...] [-o OUTFILE]
PARAMETERS
-o, --output=FILE
Output PDF filename (required unless stdout).
-p, --pagesize=SIZE
Page size (e.g., A4, letter, 210x297mm).
--border=W:H
Page border width:height in mm (default: 0:0).
--fit=[shrink|expand|both]
Fit images to page size.
--rotation=ANGLE
Rotate pages (0, 90, 180, 270 degrees).
--nocrop
Disable automatic cropping to image bounds.
--optimize=0|1|2
PDF optimization level (2 most aggressive, lossless).
--password=PASSWORD
Set owner password for PDF encryption.
--key-size=128|256
Encryption key size in bits (default: 128).
--stdin-src
Read images from stdin instead of files.
--version
Print version and exit.
--help
Show help and exit.
DESCRIPTION
img2pdf is a lightweight, command-line utility for converting images to PDF documents without any quality loss. It embeds original image data directly into the PDF, avoiding recompression, rescaling, or interpolation, which preserves pixel-perfect fidelity. This is ideal for archiving scans, photos, or high-resolution images.
Supporting formats like JPEG, PNG, TIFF, WebP via Pillow, it handles single or multiple images (each on its own page). Features include custom page sizes (e.g., A4, letter), fitting modes (shrink/expand/both), rotation, borders, cropping control, PDF optimization (reduces size losslessly), and AES encryption.
The tool is Python-based, fast for most uses, and produces standards-compliant PDFs readable everywhere. It's popular in workflows like batch-scanning documents or creating print-ready files, outperforming GUI tools or ImageMagick's convert in quality preservation and speed.
No GUI dependencies; install via pip or packages. Output can go to file or stdout for piping.
CAVEATS
Large images yield big PDFs; requires Pillow (>=5.0); no vector graphics support; limited to raster images.
EXAMPLES
img2pdf *.jpg -o output.pdf
img2pdf --pagesize A4 --fit shrink scan*.tiff -o doc.pdf
cat images/ | img2pdf --stdin-src -o out.pdf
INSTALLATION
Debian/Ubuntu: apt install img2pdf
pip: pip install img2pdf (installs Pillow auto).
HISTORY
Developed by Jakob Kummerow starting 2016; version 0.1.0 released May 2016. Actively maintained, now at v0.5+; popular for lossless conversion over ImageMagick alternatives.
SEE ALSO
convert(1), pdftoppm(1), ImageMagick(1)


