Before finding this answer I ended up with a slightly different strategy:
- (specific to me)
-resize
images if they have different scale (dpi)
- Position each image in a canvas of the desired merged dimensions (
left+right-overlap
):
-extent
are the final dimensions
-gravity
positions each image on the top/bottom left/right
-background none
so the empty part aren't white
- pile them up with
-composite
(ImageMagick 7 code, just replace magick
with convert
for IM6)
sz=1105x1155
magick \
\( \( right.jpg -resize 924x724^ \) \
-background none -gravity northeast -extent $sz \) \
\( left.jpg -background none -gravity southwest -extent $sz \) \
-composite result.jpg
This seems less elegant than the existing answers, for example -mosaic
used by @Mark Setchell is smarter, according to the docs:
Rather than only creating an initial canvas based on just the canvas size of the initial image, the Mosaic Operator creates a canvas that is large enough to hold all the images (in the positive direction only).
... but maybe some use-case will prefer giving the merged canvas size or need -composite
options.