Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,27 @@ renderStream.on('data', function(data) {
});
```

An example using a buffer to store the image temporarily instead of a file:

```javascript
var webshot = require('webshot');
var fs = require('fs');
var lwip = require('lwip');

var renderStream = webshot('google.com');
var buffer = new Buffer('')

renderStream.on('data', function(data) {
buffer = concat([buffer, data])
});
renderStream.on('end', function(){
// do whatever you want with your buffer
fs.writeFileSync('/my-folder/my-image.png', buffer, {encoding:'base64'}) // save it as file
console.log('<img alt="My Screenshot" src="data:image/png;base64,'+buffer.toString()+'" />') // print the inline html image code
lwip.open(buffer, 'png', function(err, image){}) // open it for further modification using lwip
}
```

An example showing how to take a screenshot of a site's mobile version:

```javascript
Expand Down