PhantomJS - renderBase64()



This method takes the screen capture and gives the image as a string in base46. The renderbase64 method supports formats like PNG, JPEG and JPG. It does not support GIF as of now. You can use the clipRect property to define the portion for image capture.

Syntax

Its syntax is as follows −

wpage.renderBase64('PNG'); 

Example

var wpage = require('webpage').create(); 
wpage.open('http://localhost/taks/wopen2.html', function (status) { 
   var base64 = wpage.renderBase64('PNG'); 
   console.log(base64); 
   phantom.exit(); 
}); 

The above program generates the following output.

iVBORw0KGgoAAAANSUhEUgAAAZAAAAE3CAYAAACEpheaAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAgAEl 
E 
QVR4nO3dv3OjSL8u8Ee33mA3uuXszGZnSnLd8jo6b4b+AmkS38R1TjQZCqXEmave3SpnTiC0am8w6UR 
O 
phantomjs_webpage_module_methods.htm
Advertisements