Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compare similar images and return: (pixels, diff_image) #238

willjs12 opened this issue May 15, 2015 · 0 comments

Compare similar images and return: (pixels, diff_image) #238

willjs12 opened this issue May 15, 2015 · 0 comments


Copy link

@willjs12 willjs12 commented May 15, 2015

Would love to see Wand support the equivalent to this command line usage. This is supported by the 'RMagick" ruby gem.

diff_file = tempfile.NamedTemporaryFile(delete=False)
command = 'compare -metric AE ' + file1 + ' ' + file2 + ' ' + + ' ' + '2>&1'
proc = subprocess.Popen(command, stdout=subprocess.PIPE, shell=True, universal_newlines=True)
(out, err) = proc.communicate()
   pixels = int(float(out))  # pixels is the total number of pixels that were different
   print('Image comparison failed: ' + out)
   # diff_file contains an image showing all of the pixels in the 2 images where the pixels that were
   # different are red, and the pixels that were the same are lightened
   diff_img = Image( 

The equivalent code using the ruby gem looks like this:

img1 =
img2 =
diff_img, pixels = img1.compare_channel(img2, Magick::AbsoluteErrorMetric)
@dahlia dahlia added the enhance label May 15, 2015
@dahlia dahlia closed this in b7efb6a Dec 21, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.