将两个文件的对比差异生成图片
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
diff
log
README.md
example.php

README.md

CreateDiffPic

实现方法:生成两个文件的对比网页,然后用PhantomJS将网页生成图片。详情请见example.php:

  <?php
    define("SITE_PATH", dirname(__FILE__));
    $old_path = SITE_PATH."/log/old";
    $new_path = SITE_PATH."/log/new";
    $js_path = SITE_PATH."/diff/deal.js";
    $request_url = "http://10.16.15.225/diff/index.php"; //根据自己的网络设置,即访问diff目录下的index.php文件
    $img_path = SITE_PATH."/log/diff.png";
    $command = "/usr/bin/phantomjs {$js_path} {$request_url} {$img_path}";
    shell_exec($command);
  ?>

生成图片效果: image

PhantomJS: http://phantomjs.org