Skip to content

Instantly share code, notes, and snippets.

@CloudyPadmal
Created February 10, 2022 12:36
Show Gist options
  • Save CloudyPadmal/f1336cb55a7bcf08a76b01132230803a to your computer and use it in GitHub Desktop.
Save CloudyPadmal/f1336cb55a7bcf08a76b01132230803a to your computer and use it in GitHub Desktop.
Bash script to view the difference between two images.
#!/bin/bash
IMG1=${1};
IMG2=${2};
convert -colorspace gray -density 300 $IMG1 t1.jpg
convert -colorspace gray -density 300 $IMG2 t2.jpg
composite -stereo 0 t1.jpg t2.jpg RESULT.jpg
rm -rf t1.jpg t2.jpg
############################################################################
# Blue: Only in image 1
# Red: Only in image 2
# You will need Imagemagick tool :: sudo apt-get install imagemagick-6.q16
# $ ./image-diff.sh image1.jpg image2.jpg
# $ ./image-diff.sh image1.eps image2.eps
# This will generate a RESULT.jpg in the same directory
# For .eps files, edit the policy file at /etc/ImageMagick-xx/policy.xml and
# uncomment to enable ghost script for PS and EPS.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment