Converting several .jpg into a multipage .pdf - with external margins

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
floppyzedolfin
Posts: 4
Joined: 2016-06-25T03:22:07-07:00
Authentication code: 1151

Converting several .jpg into a multipage .pdf - with external margins

Post by floppyzedolfin »

Hello,
Here is my situation : I have several .jpg files that have roughly the same size (360*510) that I would like to concatenate into a .pdf file so that I can print only one file and reduce the amount of non-printed pagespace.

In order to achieve this, I used montage :
montage -geometry 360x510+2+2 -mode concatenate -tile 3x3 *.jpg output.pdf

This does approximately what I want : it does generate a multipage .pdf file with, on each page, 9 of my .jpgs, with a small whitespace between them.

However, it has only 2 pixels inner margin on the sides, which isn't acceptable for print - I would need something like 2cms (let's make it simple and have the same margin on vertical and horizontal edges) on each side of my .pdf pages.
Is there any way I can achieve this with command-lines?

Thanks a lot!
floppyzedolfin
Posts: 4
Joined: 2016-06-25T03:22:07-07:00
Authentication code: 1151

Re: Converting several .jpg into a multipage .pdf - with external margins

Post by floppyzedolfin »

It seems I found a way.
Relaunch a montage on the output.pdf file :

montage -geometry +50+50 -mode concatenate -tile 1x1 output.pdf outputEdges.pdf

this sort of does what I want.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Converting several .jpg into a multipage .pdf - with external margins

Post by fmw42 »

You could have just added a border around the outside using -border
floppyzedolfin
Posts: 4
Joined: 2016-06-25T03:22:07-07:00
Authentication code: 1151

Re: Converting several .jpg into a multipage .pdf - with external margins

Post by floppyzedolfin »

I did try the -border option, but it added a border to each of my .jpg files, and thus created wide borders within the pages, rather than on their borders.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Converting several .jpg into a multipage .pdf - with external margins

Post by fmw42 »

You have to pipe the output from montage to a convert to add the border. It is similar to what you did with a second montage, but just using the simpler -border.
Post Reply