brenden / node-webshot

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

renderStream is not working for me. #231

Open gourav1gourav opened 6 years ago

gourav1gourav commented 6 years ago

I need to convert the html to image but in base64 format. Currently i am only able to convert to image. I am getting the image in the local folder when ever i am calling this api in front end. But i dont need to store in local folder i need the base64 string for the html encoded.

app.post('/api/screencapture', function (req, res) { ImgId = Math.floor(Date.now() / 1000); imgName = ImgId + '_capture.png' imgUrl = __dirname + '/public/' + imgName;

imgPath = {}; imgPath.imgpath = imgName;

webshot(req.body.html, imgUrl, options, (err) => {

});

});

Please help me i tried a lot and stuck there.

thanks in advance

drexdelta1 commented 6 years ago

me too :( .

brittneykernan commented 5 years ago

You need to remove the imgUrl from arguments.

let body = "data:" + "image/png" + ";base64,"; const renderStream = webshot(camUrl, options).on('data', function(data) { body += data.toString('base64'); }).on('end', () => { console.log(body); console.log(Screenshot taken!); });

gourav1gourav commented 5 years ago

Thanks Brenden I will check it.

On Thu, Feb 14, 2019, 4:44 AM Brittney Kernan <notifications@github.com wrote:

You need to remove the imgUrl from arguments.

let body = "data:" + "image/png" + ";base64,"; const renderStream = webshot(camUrl, options).on('data', function(data) { body += data.toString('base64'); }).on('end', () => { console.log(body); console.log(Screenshot taken!); });

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/brenden/node-webshot/issues/231#issuecomment-463414548, or mute the thread https://github.com/notifications/unsubscribe-auth/ALmd3MQD_0-hN1z97h7TzacTlYCjmvrfks5vNJw8gaJpZM4S_eAi .