brenden / node-webshot

Easy website screenshots in Node.js
2.12k stars 286 forks source link

using siteType=file , img not displaying in output png #133

Open gregmercer opened 8 years ago

gregmercer commented 8 years ago

I'm trying to use siteType='file' on a very simple .html file that contains an img tag, but I'm not seeing the image in the output .png file - simple.png

I'm using phantomjs 2.0 by setting the following option: phantomPath: require('phantomjs2').path,

Here is the specific code I'm using: https://github.com/gregmercer/webshot-simple/tree/master

var webshot = require('webshot');

var options = {
  siteType: 'file',
  phantomPath: require('phantomjs2').path,
  defaultWhiteBackground: true,
  userAgent: 'Mozilla/5.0 (iPad; CPU OS 5_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9B176 Safari/7534.48.3',
  //timeout: 4000,
  phantomConfig: {
    "ignore-ssl-errors": "true",
    "ssl-protocol": "any"
  },
  settings: {
    resourceTimeout: 6000
  },
  renderDelay: 6000
};

webshot('simple.html', 'simple.png', options, function(err) {
  // screenshot now saved to chess-board.png
});
brenden commented 8 years ago

Huh strange. When I tried this without setting phantomPath it worked fine. Currently I'm unable to install phantomjs2 due to this issue: https://github.com/zeevl/phantomjs2/issues/10. However now that the phantomjs-prebuilt module is released I'm going to switch to that soon, and maybe that will fix this.