Skip to content

Instantly share code, notes, and snippets.

@cpelley
Last active November 4, 2016 08:44
Show Gist options
  • Save cpelley/63c3b17e6b3ff7514d5430f9119b9992 to your computer and use it in GitHub Desktop.
Save cpelley/63c3b17e6b3ff7514d5430f9119b9992 to your computer and use it in GitHub Desktop.
Commandline image diff utility
#!/bin/sh
# Function to diff an image using imagemagick, displaying the original images
# and the diff.
#
# Add this file to your PATH to make available and ensure that it has
# executable privileges.
#
# Example usage:
# imgdiff <image1> <image2>
# http://askubuntu.com/questions/209517/does-diff-exist-for-images
compare -compose src $1 $2 tmp_difference.png
convert +append $1 $2 tmp_difference.png tmp_difference_comb.png
display tmp_difference_comb.png
shift && shift
case $* in
--delete|-d)
echo 'Cleaning up diff images.'
rm -f tmp_difference.png tmp_difference_comb.png
;;
*)
echo 'Unrecognised command: '$*
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment