0.0.2 • Published 4 years ago

eml2png v0.0.2

Weekly downloads
7
License
MIT
Repository
github
Last release
4 years ago

eml2png-nodejs

npm npm npm Known Vulnerabilities Coverage Status

Paint the EML to a single PNG image.

Requirements

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

Online Demo