eml2png
Version:
Paint the EML to a single PNG image.
68 lines (48 loc) • 2.18 kB
Markdown
[](https://www.npmjs.com/package/eml2png)
[](https://www.npmjs.com/package/eml2png)
[](https://www.npmjs.com/package/eml2png)
[](https://snyk.io//test/github/poipoii/eml2png-nodejs?targetFile=package.json)
[](https://coveralls.io/github/poipoii/eml2png-nodejs?branch=master)
Paint the EML to a single PNG image.
* [nodejs](http://nodejs.org/) v8 or later.
* [wkhtmltopdf/wkhtmltoimage](http://wkhtmltopdf.org/) v0.12 (with patched qt) or later.
The latest and greatest version of this software is available through [npm](http://npmjs.org/).
npm install eml2png
```javascript
// include the node module
const wkhtmltox = require('eml2png');
// Locations of the binaries can be specified, but this is
// only needed if the programs are located outside your PATH
process.env.WKHTMLTOIMAGE = '/opt/local/bin/wkhtmltoimage';
// instantiate a new converter.
const converter = new eml2png();
// Convert from file path and save into disk
const eml_8 = 'test/messages/wordpress.eml';
converter.png(eml_8, {}, eml_8 + '.png').then(result => {
console.log(result);
});
// Convert from file path and return a stream
converter.png(eml_8).then(result => {
if (result) {
result.pipe(fs.createWriteStream(eml_8 + '.png')).on('finish', function() {
console.log('done', eml_8);
});
} else {
console.log(eml_8, result);
}
});
// Convert from string
const fs = require('fs');
const data = await fs.readFileSync(eml_8, 'utf8');
converter.png(data, {}, eml_8 + '.data.png').then(result => {
console.log(result);
});
```
- See [example/README.md](https://github.com/poipoii/eml2png-nodejs/blob/master/example/README.md).
- See [eml2png-nodejs.glitch.me](https://eml2png-nodejs.glitch.me/).