undefinedfix
Sign in

With nodejs as the background, can the page text be converted into pictures?

dipuk edited in Wed, 26 Aug 2020

Want to do a small project, hope to realize the function of generating text into pictures in the web page, and then show it.

If you only rely on the front end, it seems that you can use < canvas >, but you don't want to be the first choice.

If the background is based on nodejs, can this function be realized? What is the principle?

Thank you~

3 Replies
vitakot
commented on Wed, 26 Aug 2020

Ha ha, I have done similar projects, that is, rendering web pages into pictures, using this tool casperjs, documents here, the principle is to use a WebKit kernel browser without interface, after rendering on the server side, export them into PNG. Here is the simplest example

//test.js

var page = require('webpage').create();
var targetURL = 'http://www.baidu.com';
page.open(targetURL, function(status) {
    console.log("Status: " + status);
    if (status === "success") {
        page.render('pc.jpg');
    }
    phantom.exit();
});
implement casperjs.cmd test.js

give the result as follows

suxbr
commented on Thu, 27 Aug 2020

direct SVGhttps://www.npmjs.com/package... Or SVG to Ca nvashttps://github.com/dodo/node-...

If you need to transfer to jpg/ pnghttps://github.com/shakiba/sv...

pmioo
commented on Thu, 27 Aug 2020

The backend nodejs can also be generated with canvas.

You can refer to this: http://blog.csdn.net/qxs96526...

lock This question has been locked and the reply function has been disabled.