 How to compare two images, check two image are same or not
You can compare two images using imagemagick.
You can download imagemagick from here. Version must be greater than 6.0. (like ImageMagick-6.4.3-Q16). Suppose you install in "C:\Program Files " folder then you can run command from this location C:\Program Files\ImageMagick-6.4.3-Q16>

After successfully installation you can use this below command
C:\Program Files\ImageMagick-6.4.3-Q16>compare -metric AE 5001.MAIN.jpg 5002.MAIN.jpg difference.jpg
if it returns value 0 means both images are same.

Even you can use -verbose attribute with this command to get more output.
C:\Program Files\ImageMagick-6.4.3-Q16>compare -verbose -metric AE 5001.MAIN.jpg 5002.MAIN.jpg difference.jpg

You can check this command with two different images, two same images.

There are some more command
C:\Program Files\ImageMagick-6.4.3-Q16> compare -compose src rose.jpg reconstruct.jpg difference.png
C:\Program Files\ImageMagick-6.4.3-Q16> compare -verbose -metric mae rose.jpg reconstruct.jpg difference.png
C:\Program Files\ImageMagick-6.4.3-Q16> compare -channel red -metric PSNR rose.jpg reconstruct.jpg difference.png

You can get more info from these link
http://www.imagemagick.org/script/compare.php
http://www.imagemagick.org/Usage/compare/

http://www.imagemagick.org/script/compare.php

http://stackoverflow.com/questions/20533323/compare-two-images-with-imagemagick

imagemagick:

  AE     absolute error count, number of different pixels (-fuzz effected)
  FUZZ   mean color distance
  MAE    mean absolute error (normalized), average channel error distance
  MEPP   mean error per pixel (normalized mean error, normalized peak error)
  MSE    mean error squared, average of the channel error squared
  NCC    normalized cross correlation
  PAE    peak absolute (normalized peak absolute)
  PHASH  perceptual hash
  PSNR   peak signal to noise ratio
  RMSE   root mean squared (normalized root mean squared)
  
  
probléme: le fichier de sortie est vide !!!!  compare -metric AE -fuzz 2000 1.png 2.png diff.png 2> tmp.txt
  
myOutput=subprocess.Popen("C:\\usr\\local\\bin\\att\\compare.exe -metric AE -fuzz 100 1.png 2.png mask.png", stdout=subprocess.PIPE, stderr=subprocess.STDOUT)

output = subprocess.Popen(["compare","-metric","PSNR",path + "before.jpg", path + "after.jpg", path + "difference.jpg"], stderr=subprocess.PIPE).stderr
score = output.read()


https://gist.github.com/mike-gill/6066331

 def find_tiff_diff(self, new_tif, old_tif, out_diff_tif, compare_exe):
command = ("%s -quiet -metric AE %s %s -compose Src -highlight-color White -lowlight-color Black %s" %
(compare_exe, new_tif, old_tif, out_diff_tif))
process = subprocess.Popen(command,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
stdout = process.communicate()[0]
return int(float(stdout.strip()))

  