Side by side images

Quick script. As I’ve got FLIR images of my house, I wanted to have them side by side – original image + FLIR. So I wrote some small (fast) script in bash to do that.

#!/bin/bash

ir=IR_
img=DC_

im_start=$1
ir_start=$((im_start-1))

echo "Starting from $start - $(printf "%s%04d.jpg" $img $im_start)"
echo "IR will be from $ir_start - $(printf "%s%04d.jpg" $ir $ir_start)"

if [[ ! -f "$(printf "%s%04d.jpg" $img $im_start)" ]]; then
  echo "Image doesn't exist!"
  exit
fi

if [[ ! -f "$(printf "%s%04d.jpg" $ir $ir_start)" ]]; then
  echo "IR doesn't exist!"
  exit
fi

loop=1

while [ $loop -ne 0 ];do

  image=$(printf "%s%04d.jpg" $img $im_start)
  ir_image=$(printf "%s%04d.jpg" $ir $ir_start)

  combined_image=$(printf "flir-%04d-%04d.jpg" $im_start $ir_start)

  echo -n "$image + $ir_image --> $combined"
  montage -mode concatenate -tile x1 $image $ir_image $combined_image
  echo "..Done!"

  # increase
  im_start=$((im_start+2))
  ir_start=$((ir_start+2))

  #echo "Next file $(printf "%s%04d.jpg" $img $im_start)"

  # test if file?
  if [[ ! -f "$(printf "%s%04d.jpg" $img $im_start)" ]]; then
    loop=0
  fi
done

And the resulting image:

flir-0941-0940

Leave a Reply

Your email address will not be published. Required fields are marked *

3 × = 3