Marius Hauken

How to Combine Images into a PDF in macOS Terminal

updated: #productivity #development

Sometimes I need to turn a folder of images into one PDF. Preview works, but Terminal is handy when there are lots of files or I need to repeat the same task.

The short version, with ImageMagick installed:

magick *.jpg output.pdf

Each image becomes a page. Your original images stay in the folder.

Install ImageMagick

If you already use Homebrew, run:

brew install imagemagick

Check that it is available:

magick -version

This guide uses ImageMagick 7’s magick command. Older examples, including the original version of this post, used convert.

Create the PDF

In Terminal, type cd followed by a space, drag your image folder from Finder into the Terminal window, then press Return.

For JPG files:

magick *.jpg output.pdf

For PNG files:

magick *.png output.pdf

The PDF appears in the same folder. Choose a new output name if you want to keep an earlier result.

Put the pages in the right order

The shell expands *.jpg in filename order. Use names such as 01-cover.jpg, 02-details.jpg, and 03-receipt.jpg, or list the files in your preferred order:

magick 01-cover.jpg 02-details.jpg output.pdf

Quote filenames containing spaces:

magick "cover image.jpg" "details image.jpg" output.pdf

Make a smaller PDF

For photographs, try JPEG compression:

magick *.jpg -compress JPEG -quality 70 smaller.pdf

Check that small text is still readable. Compression is a tradeoff, so keep the originals and compare the result.

If Terminal reports that it cannot find matching files, check the folder and file extension: *.jpg will not match .jpeg or .png files. If it reports a PDF security-policy error, consult the ImageMagick security policy documentation for your installation.

I checked these examples with ImageMagick 7 on macOS in October 2026. See the official ImageMagick 7 migration guide and compression options.

Already have PDFs? Use qpdf to combine existing PDF files instead.