OLD | NEW |
1 #!/usr/bin/python2.4 | 1 # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 # Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | |
3 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 3 # found in the LICENSE file. |
5 | 4 |
6 """Compare two images for equality, subject to a mask.""" | 5 """Compare two images for equality, subject to a mask.""" |
7 | 6 |
8 from PIL import Image | 7 from PIL import Image |
9 from PIL import ImageChops | 8 from PIL import ImageChops |
10 | 9 |
11 import os.path | 10 import os.path |
12 | 11 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 if mask.size != im1.size: | 48 if mask.size != im1.size: |
50 return ("The mask is of a different size than the images (%r vs %r)" % | 49 return ("The mask is of a different size than the images (%r vs %r)" % |
51 (mask.size, im1.size), mask) | 50 (mask.size, im1.size), mask) |
52 | 51 |
53 diff = ImageChops.multiply(diff, mask.convert(diff.mode)) | 52 diff = ImageChops.multiply(diff, mask.convert(diff.mode)) |
54 | 53 |
55 if max(diff.getextrema()) != (0, 0): | 54 if max(diff.getextrema()) != (0, 0): |
56 return ("The images differ", diff) | 55 return ("The images differ", diff) |
57 else: | 56 else: |
58 return None | 57 return None |
59 | |
60 | |
61 | |
OLD | NEW |