Script to compare images pixel-by-pixel for optipng validation.
Requires Python and PIL.
This commit is contained in:
parent
627f8b7c61
commit
45fa9d2c52
1 changed files with 42 additions and 0 deletions
42
utils/compare_images.py
Executable file
42
utils/compare_images.py
Executable file
|
@ -0,0 +1,42 @@
|
|||
#!/usr/bin/env python
|
||||
#
|
||||
# Script to compare images pixel-by-pixel to detect corruption due to
|
||||
# problems in tools such as optipng.
|
||||
#
|
||||
# Takes two files as arguments, each being a list of image files.
|
||||
# Images are being compared between the two lists, one by one.
|
||||
|
||||
# Run-time requirements: Python, PIL (Python Imaging Library)
|
||||
#
|
||||
# Copyright (C) 2011 by Karol 'grzywacz' Nowak (grywacz@gmail.com)
|
||||
#
|
||||
# Part of the Battle for Wesnoth Project <http://www.wesnoth.org>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License version 2 or,
|
||||
# at your option any later version. This program is distributed in the
|
||||
# hope that it will be useful, but WITHOUT ANY WARRANTY. See the COPYING
|
||||
# file for more details.
|
||||
#
|
||||
from sys import argv, exit
|
||||
|
||||
try:
|
||||
import Image as PIL
|
||||
except ImportError, e:
|
||||
print "Unable to import PIL (Python Imaging Library)"
|
||||
raise e
|
||||
|
||||
list1 = open(argv[1])
|
||||
list2 = open(argv[2])
|
||||
|
||||
for path1, path2 in zip(list1, list2):
|
||||
path1 = path1.strip()
|
||||
path2 = path2.strip()
|
||||
|
||||
image1 = PIL.open(path1)
|
||||
image2 = PIL.open(path2)
|
||||
|
||||
if image1.tostring() != image2.tostring():
|
||||
print path1 + " and " + path2 + " differ!"
|
||||
|
||||
# vim: set ts=4:sw=4:expandtab
|
Loading…
Add table
Reference in a new issue