export_to_png
Convert Excalidraw drawings to PNG format with customizable quality, scale, and display options for sharing or embedding.
Instructions
Export an Excalidraw drawing to PNG
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"id": "<id>"
},
"name": "export_to_png"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | ||
| quality | No | ||
| scale | No | ||
| exportWithDarkMode | No | ||
| exportBackground | No |
Implementation Reference
- src/operations/export.ts:46-67 (handler)Core handler function that executes the export_to_png tool logic: fetches the drawing by ID and returns a base64-encoded PNG image (placeholder implementation).
export async function exportToPng( id: string, quality: number = 0.92, scale: number = 1, exportWithDarkMode: boolean = false, exportBackground: boolean = true ): Promise<string> { try { // Get the drawing const drawing = await getDrawing(id); // Return the PNG content as a base64 string // Note: In a real implementation, we would use the Excalidraw API to convert the drawing to PNG // For now, we'll just return a placeholder return 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg=='; } catch (error) { if (error instanceof ExcalidrawResourceNotFoundError) { throw error; } throw new Error(`Failed to export drawing to PNG: ${(error as Error).message}`); } } - src/operations/export.ts:11-17 (schema)Zod schema defining the input parameters for the export_to_png tool.
export const ExportToPngSchema = z.object({ id: z.string().min(1), quality: z.number().min(0).max(1).optional().default(0.92), scale: z.number().min(0.1).max(5).optional().default(1), exportWithDarkMode: z.boolean().optional().default(false), exportBackground: z.boolean().optional().default(true), }); - index.ts:93-95 (registration)Registration of the export_to_png tool in the ListTools response, including name, description, and input schema.
name: "export_to_png", description: "Export an Excalidraw drawing to PNG", inputSchema: zodToJsonSchema(exportOps.ExportToPngSchema), - index.ts:161-172 (handler)Server-side handler in the CallToolRequest switch that parses arguments and invokes the exportToPng function.
case "export_to_png": { const args = exportOps.ExportToPngSchema.parse(request.params.arguments); const result = await exportOps.exportToPng( args.id, args.quality, args.scale, args.exportWithDarkMode, args.exportBackground ); return { content: [{ type: "text", text: result }], };