#!/bin/bash
######################################################################
#Copyright (C) 2019 Kris Occhipinti
#https://filmsbykris.com
#This program is free software: you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation, either version 3 of the License, or
#(at your option) any later version.
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#GNU General Public License for more details.
#You should have received a copy of the GNU General Public License
#along with this program. If not, see <http://www.gnu.org/licenses/>.
######################################################################
#Compares two images
if [ "$#" -lt 1 ]
then
echo "Usage: $0 image_1.jpg image_2.jpg"
exit 1
fi
#difference file
d="/tmp/compare-diff.png"
i1="$1"
i2="$2"
let v="$(compare -verbose -metric mae "$i1" "$i2" "$d" 2>&1 >/dev/null | grep 'all:'| awk '{print $2}'|cut -d\. -f1)"
echo "Difference is $v."
echo "Larger the number the less the images match."
echo "If the Difference is 0 then it is an exact match."
if [ "$v" -eq 0 ]
then
echo "They are the same image"
elif [ "$v" -lt 1000 ]
then
echo "They are some what the same."
else
echo "They are very different."
fi