14

I have some images which I want to merge. By this I mean that if I have 5 images, I want to arrange them in this way:

tiling layout

I want to do this using a command so that I can use a Bash script for it. For example the command could be like this:

foo image1 image2 image3 image4 image5

I have lots of images so the command should be able to process a large number of files.

The output can be PDF or even in image format.

4
  • Are they all the same size?
    – Tim
    Aug 12, 2014 at 10:22
  • @Tim yes they are on the same size. I have 29 chart which I want to put them all near each other in one pdf or png file Aug 12, 2014 at 10:23
  • @Tim how to vote your edit? :) Aug 12, 2014 at 10:30
  • 2
    Oh no, not posisble :) but thanks. I've got quite quick on inkscape, it only took a few minutes!
    – Tim
    Aug 12, 2014 at 10:31

2 Answers 2

20

See the montage command from imagemagick (sudo apt-get install imagemagick).

montage -geometry 250x250+0+0 image1.png image2.png out.png

This will resize each image (to 250px with no deformation) and combine them with no margin.

More montage examples.


You can also use convert (example with wildcards):

convert -append pixpixp-*.jpg newpix.jpg
6

I was doing something similar the other day. Grids are in, it seems. In my case I had a variable number of images being piped into the grid and I just wanted to create a 17 wide image by however many images tall.

montage -mode concatenate $(printf 'rose: %.0s' {1..136}) -resize 100x80 -tile 17x output.jpg

That just uses 136 rose images to form a 8-tile-high grid. Obviously you'll want to change the $(...) group for a list of your input images. And you'll want to set the tile variable to something like 2x if you just want to set the number of tiles.

In terms of outputting to PDF, you can just change the extension. So you would be looking at something like:

montage -mode concatenate $(printf 'rose: %.0s' {1..5}) -tile 2x out.pdf

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .