こうする async function loadAsImage(svg) { return new Promise((resolve, reject) => { const svgXml = new XMLSerializer().serializeToString(svg); const blob = new Blob([svgXml], { type: 'image/svg+xml' }); const url = URL.createObjectURL(blob); const img = new Image(); img.onload = () => { URL.revokeObjectURL(url); resolve(img); }; img.onerror = (e) => { URL.revokeObjectURL(url); reject(e); }; img.src =