Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # a tiny file differ (creates a PPM image)
- WIDTH = 32
- WHITE = "\xff\xff\xff"
- RED = "\xff\0\0"
- import sys
- filename1, filename2, imagename = sys.argv[1:4]
- with open(filename1, "rb") as f:
- d1 = f.read()
- with open(filename2, "rb") as f:
- d2 = f.read()
- assert len(d1) == len(d2)
- HEIGHT = (len(d1) / WIDTH) + 1
- pixels = []
- for i,j in enumerate(d1):
- pixels.append(WHITE if d1[i] == d2[i] else RED)
- #remaining pixels will be black
- with open(imagename, "wb") as f:
- f.write("P6 %i %i 255 " % (WIDTH, HEIGHT))
- f.write("".join(pixels))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement