A powerful and flexible template rendering engine that provides a comprehensive REST API for processing, converting, and rendering templates with support for multiple formats including SVG, PSD, and more. Built with Elysia.js, this service offers advanced image manipulation capabilities and template management features.
- High-Performance Template Rendering: Convert templates to high-quality images with support for multiple formats
- Bulk Processing: Efficiently render multiple templates in a single request
- Real-time Preview: Instant HTML preview of rendered templates
- Base64 Output: Direct base64 image output for easy integration
- Dynamic Content: Support for variable replacement and dynamic text
- Multi-format Support: Render templates with various content types (SVG, images, text)
- List all available templates with pagination support
- Retrieve specific templates by ID
- Secure endpoint access with API key authentication
- Convert PSD files to templates using URL
- Dynamic variable replacement in templates
- Template customization capabilities
- Smart image resizing with width and height specifications
- Maintains aspect ratio and image quality
- Template-aware resizing algorithms
Templates in this system are JSON-based objects that support a rich set of features:
- Layered Structure: Templates can contain multiple layers including images, text, and SVG elements
- Dynamic Text: Support for text layers with customizable fonts, including Google Fonts integration
- Image Processing: Support for image masking, color replacement, and post-processing
- SVG Support: Native SVG support with color replacement capabilities
- Variable Replacement: Dynamic content replacement through template variables
- Font Management: Automatic font loading and registration from Google Fonts
- Image Masking: Advanced image masking capabilities for complex compositions
Here's a simple example of a template structure:
{
"width": 800,
"height": 600,
"pages": [
{
"background": "rgba(255,255,255,1)",
"children": [
{
"type": "text",
"text": "Hello World",
"fontFamily": "Arial",
"fontSize": 48,
"fill": "rgba(0,0,0,1)",
"x": 100,
"y": 100
},
{
"type": "image",
"src": "https://example.com/image.jpg",
"width": 400,
"height": 300,
"x": 200,
"y": 200
},
{
"type": "svg",
"src": "data:image/svg+xml;base64,...",
"width": 100,
"height": 100,
"x": 300,
"y": 300
}
]
}
]
}This template demonstrates the basic structure with:
- Page dimensions and background
- Text layer with font and position
- Image layer with dimensions and position
- SVG layer with dimensions and position
- Elysia.js - Fast and type-safe Node.js web framework
- TypeScript - For type-safe code
- Konva.js - HTML5 Canvas 2D drawing library
- @napi-rs/canvas - High-performance Node.js Canvas implementation
- node-canvas - Canvas implementation for Node.js
- HTML rendering support via @elysiajs/html
- Built-in pagination utilities
- Middleware support for authentication and security
- SVG processing and manipulation
- Google Fonts integration
- Image masking and post-processing capabilities
The service includes API key authentication middleware for secure access to endpoints (currently commented out in the routes).
POST /convert/psd- Convert PSD file to templatePOST /convert/replacement- Apply variable replacements to template
POST /render- Render a template to base64 imagePOST /render/preview- Generate HTML preview of rendered templatePOST /render/bulk- Batch render multiple templates
POST /resize- Resize template with specified dimensions
GET /templates- List all templates with paginationGET /templates/:id- Get specific template by ID
This project is licensed under the MIT License - see the LICENSE file for details.