eml2png
v0.0.2
Published
Paint the EML to a single PNG image.
Downloads
43
Maintainers
Readme
eml2png-nodejs
Paint the EML to a single PNG image.
Requirements
- nodejs v8 or later.
- wkhtmltopdf/wkhtmltoimage v0.12 (with patched qt) or later.
Installation
The latest and greatest version of this software is available through npm.
npm install eml2png
Usage
// 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);
});
Example
- See example/README.md.