Skip to content

Instantly share code, notes, and snippets.

@bbody
Created May 15, 2018 03:58
Show Gist options
  • Save bbody/25e92c6e9910d51fffc7eebabf061d00 to your computer and use it in GitHub Desktop.
Save bbody/25e92c6e9910d51fffc7eebabf061d00 to your computer and use it in GitHub Desktop.
Compares two folders of files and outputs diffs (if any) to a folder called diffs
# compare_images.sh
# Requires imagemagick `brew update && brew install imagemagick`
for entry in "$1"/*
do
if [ -f "$entry" ];then
NAME=`basename "$entry"`
DIFF=`compare -metric AE "$1/$NAME" "$2/$NAME" null: 2>&1`;
if [ "${DIFF}" -eq "0" ]; then
echo "No difference: $NAME";
else
echo "Visual difference: $NAME";
`compare "$1/$NAME" "$2/$NAME" -compose src "diffs/$NAME"`;
`cp "$1/$NAME" "diffs/${NAME%.*}_${1}.png"`
`cp "$2/$NAME" "diffs/${NAME%.*}_${2}.png"`
fi
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment