Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have some images which I want to merge. The meaning of merge is that, if I have 5 images, I want to put hem near each other is this way:

enter image description here

I want to do that command line. For example the command can be:

foo image1 image2 image3 image4 image5

I am also looking for any way which merge lots of images because I have lots of images.

By the way the output can be PDF or even in image format. And also it should be command line because I want to write that on bash file.

share|improve this question
Are they all the same size? – Tim Aug 12 '14 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 – lion Aug 12 '14 at 10:23
@Tim how to vote your edit? :) – lion Aug 12 '14 at 10:30
I mean thanks for your great great great edit. – lion Aug 12 '14 at 10:30
Oh no, not posisble :) but thanks. I've got quite quick on inkscape, it only took a few minutes! – Tim Aug 12 '14 at 10:31
up vote 18 down vote accepted

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
share|improve this answer

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
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.