All posts
Images to PDF via CLI
Pack JPEG and PNG into one PDF with img2pdf, without recompression.
Open online converterPackages to install
The img2pdf package embeds images into PDF as-is, without re-encoding them as JPEG.
img2pdf
sudo apt-get update
sudo apt-get install -y img2pdfHow to run the command
List images in page order and pass -o output.pdf. Command-line order becomes page order.
img2pdf photo.jpg -o album.pdfDockerfile example
Build a minimal Ubuntu image with the required packages and run the conversion inside the container.
FROM ubuntu:24.04
RUN apt-get update && \
apt-get install -y --no-install-recommends \
img2pdf && \
rm -rf /var/lib/apt/lists/*
WORKDIR /work
docker build -t images-to-pdf .
docker run --rm -v "$PWD:/work" -w /work images-to-pdf \
img2pdf photo.jpg -o album.pdfExample commands
Run these locally after installing the packages, or inside the container from the Dockerfile.
img2pdf photo.jpg -o album.pdfimg2pdf page1.png page2.jpg page3.png -o album.pdf