export_to_png
Convert Excalidraw drawings to PNG format for sharing, embedding, or printing. Specify quality, scale, and display preferences to customize the output.
Instructions
Export an Excalidraw drawing to PNG
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | ||
| quality | No | ||
| scale | No | ||
| exportWithDarkMode | No | ||
| exportBackground | No |
Implementation Reference
- src/operations/export.ts:52-78 (handler)Core implementation of the export_to_png tool. Validates the drawing ID, fetches the drawing data, and returns a base64-encoded PNG image (placeholder for real Excalidraw API export).export async function exportToPng( id: string, quality: number = 0.92, scale: number = 1, exportWithDarkMode: boolean = false, exportBackground: boolean = true ): Promise<string> { // Validate the ID for security validateFileId(id); 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( sanitizeErrorMessage(error, "Failed to export drawing to PNG") ); } }
- src/operations/export.ts:12-18 (schema)Zod input schema for the export_to_png tool, defining parameters like id (required), quality, scale, dark mode, and background options.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), });
- src/index.ts:95-99 (registration)Registration of the export_to_png tool in the listTools handler, providing name, description, and JSON schema derived from ExportToPngSchema.{ name: "export_to_png", description: "Export an Excalidraw drawing to PNG", inputSchema: zodToJsonSchema(exportOps.ExportToPngSchema), },
- src/index.ts:176-190 (registration)Dispatch logic for export_to_png in the CallToolRequest handler: parses arguments using the schema 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 }], }; }