Created
January 30, 2017 17:26
-
-
Save NiGhTTraX/49bd7f664e139c82039e79cc14f14e0d to your computer and use it in GitHub Desktop.
Diffing images with git
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
DIFF_PATH=/tmp/diff.png | |
MONTAGE_PATH=/tmp/montage.png | |
rm -rf $DIFF_PATH $MONTAGE_PATH | |
# Try to diff the images and create a montage with the original on | |
# the left, diff in the middle and the new one on the right. | |
DIFF=$(compare $2 $1 png:- > $DIFF_PATH) | |
# XXX: for some reason IG exits with 1 when it successfully creates the diff | |
if [[ $? == 1 ]]; then | |
montage -label Original $2 -label Diff $DIFF_PATH -label New $1 \ | |
-tile x1 -geometry '433x+4+4>' $MONTAGE_PATH | |
else | |
# If the images have different sizes the diff will fail. | |
# In this case, create a montage with just the original and the new one. | |
montage -label Original $2 -label New $1 \ | |
-tile x1 -geometry '650x+4+4>' $MONTAGE_PATH | |
fi | |
if [[ $? == 0 ]]; then | |
display $MONTAGE_PATH> /dev/null 2>&1 | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git config --global core.attributesfile '~/.gitattributes' | |
echo '*.png diff=image' > ~/.gitattributes | |
git config --global diff.image.command '~/git-imgdiff.sh' | |
apt-get install imagemagick |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment