Tool required
All you need is Imagemagick, so check if the imagemagick package is available in your Linux distribution or if it is already installed on you system.
Otherwise download and install it from the official website (Linux, macOS and Windows).
Depending on which package was installed, it can be executed as either magick montage or montage if the alias is available.
A simple collage
This will combine two images side by side.
$ montage image-1.png image-2.png collage.png
montageworks with almost any image format, and you can join as many images as you like.
Tiling
To choose the way the images will be placed, use the -tile option.
$ montage image-1.png image-2.png -tile 1x2 collage.png
It used a grid, so 1x2 argument indicates the size of the grid (columns x rows).
With a 1x2 grid, the two images will be placed one above the other.
Resizing before joining
The collage will be perfect if the two images are rectangular and the same size.
-------------------------
| image1 |
| |
-------------------------
| image2 |
| |
-------------------------
Instead, if the images are of different sizes, there will be an empty space next to one of them.
-------------------------
| image1 |
| |
-------------------------
| image2 |########
| | empty #
-----------------########
You can see it clearly adding a backround color to the collage and some padding (-geometry +horizontal_padding+vertical_padding).
$ montage image-1.png image-2.png -tile 1x2 -geometry +5+10 -background '#000000' collage.png
In order to make them aligned you can resize them to a fixed width (2000px in this case).
$ montage -resize '2000' image-1.png -resize '2000' image-2.png -tile 1x2 -geometry +5+10 -background '#000000' collage.png
This ensures that the images will be perfectly aligned in the final collage.
-------------------------
| image1 |
| |
-------------------------
| image2 |
| |
-------------------------
Notes
Geometry argoment
Many command-line options take a geometry argument to specify such things as the desired width and height of an image and other dimensional quantities. Because users want so many variations on the resulting dimensions, sizes, and positions of images (and because ImageMagick wants to provide them), the geometry argument can take many forms.
Montage features
With the huge number of options available, you can create far more complex collages than this. Refer to the documentation for more information.