A SvelteKit application for generating Open Graph (OG) images using customizable templates. This tool allows you to create social media thumbnails and preview images programmatically.
- Template-based Image Generation - Generate images using predefined templates
- PNG and SVG Output - Export images in multiple formats
- URL-based API - Generate images via HTTP requests
- SvelteKit Application - Web interface for template exploration
bun.js
- Clone the repository:
git clone https://github.com/canonical/open-graph-images-generator
cd open-graph-images-generator- Install dependencies:
bun installStart the development server:
bun devThe application will be available at http://localhost:5173
GET /opengraph/{template}?{parameters}
Parameters:
format(optional): Output format -pngorsvg(default:png)scale(optional): Scale factor for PNG output - number between 1-10 (default: 1)- Template-specific parameters (see template schemas below)
Visit the homepage at http://localhost:5173 to:
- Browse available templates
- See template previews with example data
- Click on templates to explore them in detail
- View template parameters and examples
Templates are located in src/templates/ and follow this structure:
templates/
├── {template-name}/
│ ├── index.ts # Template definition
│ ├── schema.ts # Zod validation schema
│ ├── {Template}.svelte # Svelte component
│ └── assets/ # Template assets
Each template must export:
id: Unique template identifiercomponent: Svelte componentschema: Zod validation schemawidthandheight: Image dimensionsexample: Example data for the template
- Frontend: SvelteKit with Svelte 5
- Image Generation: Satori + Resvg for SVG to PNG conversion
- Styling: Vanilla Framework (Canonical's design system)
- Validation: Zod for schema validation