text-to-image
Version:
A library for generating an image data URI representing an image containing the text of your choice.
12 lines (11 loc) • 467 B
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
const path_1 = require("path");
const fs_1 = require("fs");
exports.default = (options) => (canvas) => {
const fileName = options?.fileName ??
`${new Date().toISOString().replace(/[\W.]/g, '')}.png`;
(0, fs_1.mkdirSync)((0, path_1.resolve)((0, path_1.dirname)(fileName)), { recursive: true });
(0, fs_1.writeFileSync)(fileName, canvas.toBuffer());
return canvas;
};
;