Merge images side by side

X @urre

I share a lot of screenshots for example in Slack. Pretty often I need to show before/after iterations, with or without annotations.

I recently made a little bash function that resides in my dotfiles to merge two images together, side by side.


#!/usr/bin/env bash

# Merge two images side by side, then open in Preview
function mont() {
  montage -background '#336699' -geometry 100% ~/desktop/"$1" ~/desktop/"$2" ~/desktop/merged.png;
  open -a Preview ~/desktop/merged.png

Montage is a part of ImageMagick. Install it using brew install imagemagick


Example images



mont image.png image2.png

I do this from ~/desktop


A new image merged.png is created and opened in Preview. Convenient for adding annotations.