Skip to content

Instantly share code, notes, and snippets.

@odyniec
Created July 14, 2014 21:03
Show Gist options
  • Save odyniec/b61d3580f114e576e96f to your computer and use it in GitHub Desktop.
Save odyniec/b61d3580f114e576e96f to your computer and use it in GitHub Desktop.
Comparing two graphics files in Python (using PIL)
from PIL import Image, ImageChops
def img_identical(file1, file2):
"""
Take two image file names and return a boolean value indicating if the
images are identical.
"""
im1 = Image.open(file1)
im2 = Image.open(file2)
return ImageChops.difference(im1, im2).getbbox() is None
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment