Phạm Văn Thông
Phạm Văn Thông

Reputation: 837

How to merge mutiple part of image into one

I have 100 parts of an image and I want to merge them into one. How can I do it from command line, using tools like Imagemagick's convert or montage.

The input is small parts of an image, like this:

parts of images

And the output is:

final image

Upvotes: 0

Views: 1148

Answers (2)

fmw42
fmw42

Reputation: 53081

In Imagemagick, you can use the montage tool to merge an (MxN) array of tiles.

montage image01 image02 ... imageXX -tile MxN -geometry +0+0 result

If the images are in alphabetic order and say png, then

montage *.png -tile XxY -geometry +0+0 result.png

See https://www.imagemagick.org/Usage/montage/

Here is an example reducing the size by 50%

Input (repeated 4 times):

enter image description here

montage lena.jpg -duplicate 3 -tile 2x2 -geometry 50x50+0+0% lena_montage.jpg

enter image description here

Upvotes: 3

Azim
Azim

Reputation: 1724

You can combine images vertically or horizontally using convert from ImageMagick:

convert *.PNG -append output.PNG

and if you need something faster, use GraphicMagick:

gm convert *.PNG -append output.PNG

You can use, -append for vertical and +append for horizontal attach. Since you need both of these options, my not-a-very-clever solution would be creating the rows first, and them combining those rows vertically to get the final result.

Upvotes: 0

Related Questions