I have a serie of ten images. I would like to have them stretched to fit 5in squares centered in a single A4 PDF, one image per page.
I would need something working on Mac (in case of some local command line subtleties).
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.
Sign up to join this communityWith ImageMagick, at 300 DPI:
convert -page 2480x3508 -extent 2480x3508 -density 300 -gravity Center *.png out.pdf
The "magic" numbers 2480x3508
are the dimensions in pixels of an A4 page at 300 DPI. See here for the dimensions at other resolutions if you need something different than 300 DPI and you can't be bothered to do the scaling yourself. Add -background black
to get the images on black.
Follow the steps below:
The built-in command you have on MacOS X for scriptable image processing, is called sips
(BSD Command).
5"x5" is equal to 300x300 pixels.
Let's pretend we have thousands of *.jpg
files in our current directory, and We want them all to be converted to 5"x5" *.pdf
files and be saved in ~/Downloads/Test
directory, all we should do is:
$ for i in *.jpg; do sips -s format pdf -p 300 300 $i --out ~/Downloads/Test/$i.pdf; done
Done! Now it's Preview's turn ↴
Go to ~/Downloads/Test
, use ⌘A to select all files, now Open them With Preview, then use ⌘P, then change the Paper Size to A4, Check the Scale instead of Scale to Fit option, and use use 100% for scale. Now Save it as a new PDF file.
Voila! Here is your desired PDF file.
pdfimages
command from poppler-utils package in debian.imagemagick
, have you tried theconvert
utility that comes with it, e.g.convert image01.jpg image02.jpg photo.jpg -compress jpeg -quality 75 test.pdf
pdfimages
extracts raster images from PDF files. The OP wants the converse, to construct a PDF from a set of images.-page A4
,-gravity center
options. e.g.convert -page A4 image01.jpg image02.jpg image03.jpg -gravity center -format pdf test.pdf