node-image-from-html
Version:
This single-dependency library provides a simple API to render HTML content using <a href="https://github.com/puppeteer/puppeteer">Puppeteer</a> (A headless chromium brower) into png and jpeg images, insuring security and efficiency in the process. Writte
12 lines (11 loc) • 383 B
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.toDataUri = void 0;
/**
* Converts a buffer into a DataURI for embedding within html.
* @param input The input to be converted.
*/
function toDataUri(input, imageType = "png") {
return `data:image/${imageType};base64,${input.toString("base64")}`;
}
exports.toDataUri = toDataUri;
;