Skip to content

Commit b1086e4

Browse files
committed
PNG compare script can now output visual diffs
1 parent 65b5bb9 commit b1086e4

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

script/refpngcompare.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
parser.add_argument("render_dir", help = "Path of the Generated directory")
1313

14+
parser.add_argument("-d", help = "Specifies whether a diff of images is output")
15+
1416
args = parser.parse_args()
1517

1618
for dir, dirs, files in os.walk(args.ref_dir):
@@ -31,6 +33,17 @@
3133
r = float(m.group(2))
3234
if (r > 0.0001) :
3335
print(reffile + ": " + str(r))
36+
if args.d is not None:
37+
diffdir = args.d
38+
#diffdir = os.path.join(args.d, os.path.relpath(dir, args.ref_dir))
39+
if not os.path.exists(diffdir):
40+
os.makedirs(diffdir)
41+
difffile = os.path.join(args.d, os.path.relpath(dir, args.ref_dir) + "-" + file)
42+
p1 = subprocess.Popen(["compare", reffile, genfile, "png:-"], stdout=subprocess.PIPE)
43+
p2 = subprocess.Popen(["montage", "-mode", "concatenate", reffile, "-", genfile, difffile], stdin=p1.stdout)
44+
p1.stdout.close()
45+
p2.communicate()
46+
3447

3548
# elif not fnmatch.fnmatch(file, 'manifest.json'):
3649
# try:

0 commit comments

Comments
 (0)