Is it possible to render web content over a clear background using WebKit?

后端 未结 5 1513
名媛妹妹
名媛妹妹 2020-12-04 10:52

I\'m trying to gauge the possibility of a patch to WebKit which would allow all rendered graphics to be rendered onto a fully transparent background.

The desired eff

5条回答
  •  盖世英雄少女心
    2020-12-04 11:30

    I have a new solution which is really easy to do, for a single screenshot. It's using node.js with phantom.js library.

    1. install node.js
    2. run 'npm install -g phantomjs' in console/terminal
    3. save the following as script.js and run it from console 'phantomjs script.js'

      var page = require('webpage').create();
      page.viewportSize = { width: 1920, height: 1500 };
      page.open("http://www.theWebYouWantToRender");
      page.onLoadFinished = function(status) {
          page.evaluate(function() {
              document.body.style.background = 'transparent';
          });
      
          page.render('render.png');
          phantom.exit();
      };
      
    4. profit? :) enjoy

提交回复
热议问题