img2pdf
converts images to PDF without re-encoding, preserving the original image
TLDR
Convert images to PDF
SYNOPSIS
img2pdf [options] [images ...] -o output.pdf
DESCRIPTION
img2pdf converts images to PDF without re-encoding, preserving the original image quality. Unlike tools that rasterize images, img2pdf embeds the original JPEG, PNG, TIFF, or other image data directly into the PDF structure.
This lossless approach means a 5MB JPEG becomes approximately a 5MB PDF (plus minimal PDF overhead), with no quality loss. Re-encoding tools would either lose quality or produce much larger files at equivalent quality.
Supported input formats include JPEG, JPEG2000, PNG (including transparency), TIFF, GIF, and others. The tool automatically handles colorspace, bit depth, and multi-page TIFFs.
Page sizing offers flexible options: natural image size (at specified DPI), fixed page sizes with fit modes, or explicit dimensions. The fit modes control how images are placed: into fits inside the page, fill fills the page (may crop), shrink only shrinks larger images.
Multiple images become multi-page PDFs in argument order. Piping from stdin enables integration with image processing pipelines.
PARAMETERS
-o, --output file
Output PDF file (required).--pagesize size
Page size: A4, Letter, Legal, or WxH (e.g., 210mmx297mm).--imgsize size
Image size: WxH with units or dpi (e.g., 300dpi).--fit mode
Fit mode: into, fill, exact, shrink.--border margin
Page borders/margins (e.g., 1cm, 1cm:2cm).--rotation angle
Rotate pages: 0, 90, 180, 270, auto.--title string
PDF title metadata.--author string
PDF author metadata.--subject string
PDF subject metadata.--keywords string
PDF keywords metadata.--creationdate date
PDF creation date.--moddate date
PDF modification date.--viewer-panes panes
Initial viewer panes: none, bookmarks, thumbs.--viewer-initial-page n
Initial page to display.--viewer-fullscreen
Open in fullscreen mode.--nodate
Don't set creation/modification dates.-S, --colorspace space
Force colorspace: RGB, L (grayscale).
CAVEATS
Only works with raster images (no vector formats). Transparent PNGs become opaque in PDF (alpha becomes white). Some viewers may struggle with large embedded images. Not all PDF features are supported (no encryption, compression control is limited).
HISTORY
img2pdf was created by Johannes Schauer Marin Rodrigues to address the common problem of converting images to PDF without quality loss. Existing tools like ImageMagick would re-encode images, causing quality degradation or size bloat. The tool is written in Python and published as a pip package.
