Skip to content

Instantly share code, notes, and snippets.

@dcommander
Last active January 25, 2022 20:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dcommander/1977746e36b3a245e334291f4d74e034 to your computer and use it in GitHub Desktop.
Save dcommander/1977746e36b3a245e334291f4d74e034 to your computer and use it in GitHub Desktop.
Scripts that facilitate using Git to track changes to photo/video content without actually committing the content
git config filter.heicfilter.clean heicsig
git config filter.heicfilter.smudge cat
git config filter.heicfilter.required true
git config filter.imgfilter.clean imgsig
git config filter.imgfilter.smudge cat
git config filter.imgfilter.required true
git config filter.vidfilter.clean vidsig
git config filter.vidfilter.smudge cat
git config filter.vidfilter.required true
cat >.gitattributes <<EOF
*.HEIC filter=heicfilter
*.heic filter=heicfilter
*.JPG filter=imgfilter
*.jpg filter=imgfilter
*.png filter=imgfilter
*.THM filter=imgfilter
*.DNG filter=imgfilter
*.dng filter=imgfilter
*.AVI filter=vidfilter
*.avi filter=vidfilter
*.MP4 filter=vidfilter
*.mp4 filter=vidfilter
*.m4v filter=vidfilter
*.MOV filter=vidfilter
*.mov filter=vidfilter
*.psd filter=vidfilter
*.CR2 filter=vidfilter
*.CRW filter=vidfilter
*.mp3 filter=vidfilter
EOF
set -u
set -e
trap onexit INT
trap onexit TERM
trap onexit EXIT
TMPFILE=
onexit() {
if [ ! "$TMPFILE" = "" ]; then
rm -f $TMPFILE
fi
}
TMPFILE=`mktemp -t imgsig`
IMAGEMAGICK_PATH=${HEICSIG_IMAGEMAGICK_PATH:-}
echo File checksum: `tee $TMPFILE | sha1sum | cut -f1 -d' '`
echo Image checksum: `${IMAGEMAGICK_PATH}convert $TMPFILE ppm:- | sha1sum | cut -f1 -d' '`
echo EXIF:
cat $TMPFILE | exiftool -n -x ExifToolVersion - |
LANG=C sed -E 's/^(Image\ Size +: )([0-9]+) ([0-9]+)(.*)$/\1\2x\3\4/g'
set -u
set -e
trap onexit INT
trap onexit TERM
trap onexit EXIT
TMPFILE=
onexit() {
if [ ! "$TMPFILE" = "" ]; then
rm -f $TMPFILE
fi
}
TMPFILE=`mktemp -t imgsig`
IMAGEMAGICK_PATH=${IMGSIG_IMAGEMAGICK_PATH:-}
echo File checksum: `tee $TMPFILE | sha1sum | cut -f1 -d' '`
echo Image checksum: `${IMAGEMAGICK_PATH}convert $TMPFILE ppm:- | sha1sum | cut -f1 -d' '`
echo EXIF:
cat $TMPFILE | exiftool -n -x ExifToolVersion - |
LANG=C sed -E 's/^(Image\ Size +: )([0-9]+) ([0-9]+)(.*)$/\1\2x\3\4/g'
set -u
set -e
trap onexit INT
trap onexit TERM
trap onexit EXIT
TMPFILE=
onexit() {
if [ ! "$TMPFILE" = "" ]; then
rm -f $TMPFILE
fi
}
TMPFILE=`mktemp -t imgsig`
echo File checksum: `tee $TMPFILE | sha1sum | cut -f1 -d' '`
echo EXIF:
cat $TMPFILE | exiftool -n -x ExifToolVersion -x Warning - |
sed -E 's/^(Image\ Size +: )([0-9]+) ([0-9]+)(.*)$/\1\2x\3\4/g'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment