@spinajs/templates-image
v3.0.26
Published
Templates support for image files. It uses puppeteer to render screenshots.
Maintainers
Readme
@spinajs/templates-image
Template renderer for generating images using Puppeteer.
Documentation
Installation
npm install @spinajs/templates-imageUsage
This package extends @spinajs/templates-puppeteer to render templates as image files (PNG, JPEG, etc.).
import { DI } from '@spinajs/di';
import { ImageRenderer } from '@spinajs/templates-image';
const renderer = await DI.resolve(ImageRenderer, [{ type: 'png', fullPage: true }]);
// the renderer's extension replaces the template's: 'template.png' reads 'template.pug'
await renderer.renderToFile('template.png', { data: 'example' }, 'output.png');Configuration
Configure via templates.image in your SpineJS configuration:
{
templates: {
image: {
static: {
portRange: [3000, 4000]
},
args: {
headless: true
},
renderDurationWarning: 5000,
navigationTimeout: 30000,
renderTimeout: 30000
}
}
}License
MIT
