I am using node-webshot and phantomjs-cli to render an html string for a png image. The html contains the image tag. The image is not displayed if the src attribute points to a local file and an error does not occur. However, it displays the image when src points to the http location. I tried all different combinations of file paths that I can think of, like
<img src=images/mushrooms.png"/> <img src=images//mushrooms.png"/> <img src=c:\images\mushrooms.png"/> <img src=c:\\images\\mushrooms.png"/> <img src=file://c:\\images\\mushrooms.png"/> <img src=file://images//mushrooms.png"/> etc..
but so far no luck. Interestingly, it works fine on my peers machine, which is a Mac, but not on mine, which is Windows, and I tried with two different Windows machines without success.
Here are some simplified codes that focus on the problem:
'use strict' const webshot = require('webshot'); console.log('generating'); webshot('<html><head></head><body><img src="c:\\images\\mushrooms.png"/></body></html>', 'output.png', {siteType: 'html'}, function(err) { console.log(err); });
The recorded code block is an example of how it works with a web link as an image source, but I need it to work with a local path.
Has anyone had this problem before knowing how to solve it?
thanks
There is no spoon
source share