Skip to content

Instantly share code, notes, and snippets.

@bradley219
Created June 24, 2014 17:16
Show Gist options
  • Save bradley219/f917ddedd802ecbcde82 to your computer and use it in GitHub Desktop.
Save bradley219/f917ddedd802ecbcde82 to your computer and use it in GitHub Desktop.
#!/bin/bash
# To configure git:
# git config difftool.imgdiff.cmd "path/to/imgdiff \"\$MERGED\" \"\$LOCAL\" \"\$REMOTE\""
# To run from git:
# git difftool -t imgdiff [<commit> [<commit>]] [--] [<path>...]
MERGED="$1"
LOCAL="$2"
REMOTE="$3"
FORMAT="Image;%Width% %Height%"
LOCAL_SIZE=`mediainfo --Inform="$FORMAT" "$LOCAL"`
REMOTE_SIZE=`mediainfo --Inform="$FORMAT" "$REMOTE"`
echo "$MERGED"
if [ "$LOCAL_SIZE" != "" ] && [ "$REMOTE_SIZE" != "" ]; then
LOCAL_WIDTH=`echo "$LOCAL_SIZE" | awk '{print $1}'`
LOCAL_HEIGHT=`echo "$LOCAL_SIZE" | awk '{print $2}'`
REMOTE_WIDTH=`echo "$REMOTE_SIZE" | awk '{print $1}'`
REMOTE_HEIGHT=`echo "$REMOTE_SIZE" | awk '{print $2}'`
DIFF_WIDTH=$(($REMOTE_WIDTH - $LOCAL_WIDTH))
DIFF_HEIGHT=$(($REMOTE_HEIGHT - $LOCAL_HEIGHT))
echo " Local: ""$LOCAL_WIDTH""x""$LOCAL_HEIGHT"" Remote: ""$REMOTE_WIDTH""x""$REMOTE_HEIGHT"" Diff: ""$DIFF_WIDTH""x""$DIFF_HEIGHT"
fi
echo ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment