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 community
With 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"
~/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 ↴
~/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.