beyond compare软件是一款对比功能很是强大的软件,它能够用来比对图片、文本、表格、MP3等等,用起来很方便、直观。最近在使用的时候,由于要批量比对不少的图片,一张一张的图片比对要一个一个打开再比对感受很麻烦,我就想能不能用脚本批量比对,我只检查批量比对出来的结果就好。还真的找到了,beyond compare支持命令行,这个软件好强大(*^_^*),有没有没有(^ ^)。html
mac版安装:python
查询官网手册,Mac上比对2个文件命令:shell
bcompare file1 file2
结果:ide
命令会直接打开beyond compare软件,而且打开要比对的2张图片。以下图所示:下图是我用命令行打开的2张图片,比对不一致的地方,默认会用红色显示工具
比对不一样类型的数据,生成报告的脚本不一样,具体的可参考官网。生成图片比对报告的脚本以下:spa
picture-report layout:<layout> [options:<options>] [title:<report title>] output-to:(printer|clipboard|<filename>) [output-options:<options>] [<comparison>]
参数说明:命令行
复制脚本到一个文件,保存文件为MyCompareScript.textcode
picture-report layout:side-by-side options:display-mismatches output-to:%3 output-options:html-color %1 %2
python 中调用命令:htm
import subprocess def compare_img(src_pic,target_pic,out_file): subprocess.Popen('bcompare -silent "@MyCompareScript" %s %s %s'%(src_pic, target_pic, out_file),shell=True)
官网文档:http://www.scootersoftware.com/v4help/blog