(url: string)
| 36 | } |
| 37 | |
| 38 | function loadImage(url: string): Promise<HTMLImageElement> { |
| 39 | return new Promise((resolve, reject) => { |
| 40 | const img = new Image(); |
| 41 | img.onload = () => resolve(img); |
| 42 | img.onerror = () => reject(new Error('The image could not be rendered.')); |
| 43 | img.src = url; |
| 44 | }); |
| 45 | } |
| 46 | |
| 47 | /** Rasterise an already-scaled SVG string to a PNG blob. */ |
| 48 | export async function svgToPng(svg: string): Promise<Blob> { |