javascript - convert HTML elements to images (server side) -
i'd convert dynamic html elements images (jpg, png, ..) , don't want screenshot of webpage nor static html file.
the purpose on server-side:
var imgs=[] (var = 0; < templates.length; i++){ var temphtml = $(templates[i]).find("#imageplaceholder").attr("src", url[i]); imgs.push(convert2image(temphtml)); }
you can use headless browser phantomjs , phantomjs bridge in order integrate application. bridge between node , phantomjs.(https://www.npmjs.com/package/phridge)
var webpage = require('webpage'); var page = webpage.create(); page.viewportsize = { width: 1920, height: 1080 }; page.open('http://youwebsite/yourpage', function (status) { var base64 = page.renderbase64('png'); phantom.exit(); console.log(base64); });
Comments
Post a Comment