index.js 848 B

123456789101112131415161718192021222324
  1. var fs = require('fs');
  2. ['top','bottom'].forEach(function(v){
  3. ['left','right'].forEach(function(h){
  4. ['1','2','3','4','5'].forEach(function(t){
  5. var inFile = 'out/'+ t +v.charAt(0) + h.charAt(0) + '.html';
  6. var outFile = 'pic/'+ t + v.charAt(0) + h.charAt(0) + '.png';
  7. var path = 'file://' + fs.absolute(inFile)
  8. var page = require('webpage').create();
  9. page.viewportSize = {
  10. width: 1000,
  11. height: 800
  12. };;
  13. page.open(path, function(status) {
  14. window.setTimeout(function () {
  15. console.log(status);
  16. page.render(outFile);
  17. setTimeout(function(){
  18. phantom.exit();
  19. }, 0);
  20. },2000);
  21. });
  22. });
  23. });
  24. });